{"action":"created","issue":{"url":"https://api.github.com/repos/pydata/pandas/issues/12187","repository_url":"https://api.github.com/repos/pydata/pandas","labels_url":"https://api.github.com/repos/pydata/pandas/issues/12187/labels{/name}","comments_url":"https://api.github.com/repos/pydata/pandas/issues/12187/comments","events_url":"https://api.github.com/repos/pydata/pandas/issues/12187/events","html_url":"https://github.com/pydata/pandas/issues/12187","id":130063386,"number":12187,"title":"Pandas interpolation enhancement request : specifying the maximum gap to interpolate.","user":{"login":"delie0512","id":16981006,"avatar_url":"https://avatars.githubusercontent.com/u/16981006?v=3","gravatar_id":"","url":"https://api.github.com/users/delie0512","html_url":"https://github.com/delie0512","followers_url":"https://api.github.com/users/delie0512/followers","following_url":"https://api.github.com/users/delie0512/following{/other_user}","gists_url":"https://api.github.com/users/delie0512/gists{/gist_id}","starred_url":"https://api.github.com/users/delie0512/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/delie0512/subscriptions","organizations_url":"https://api.github.com/users/delie0512/orgs","repos_url":"https://api.github.com/users/delie0512/repos","events_url":"https://api.github.com/users/delie0512/events{/privacy}","received_events_url":"https://api.github.com/users/delie0512/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/pydata/pandas/labels/API%20Design","name":"API Design","color":"AD7FA8"},{"url":"https://api.github.com/repos/pydata/pandas/labels/Difficulty%20Intermediate","name":"Difficulty Intermediate","color":"fbca04"},{"url":"https://api.github.com/repos/pydata/pandas/labels/Effort%20Medium","name":"Effort Medium","color":"006b75"},{"url":"https://api.github.com/repos/pydata/pandas/labels/Enhancement","name":"Enhancement","color":"4E9A06"},{"url":"https://api.github.com/repos/pydata/pandas/labels/Groupby","name":"Groupby","color":"729FCF"},{"url":"https://api.github.com/repos/pydata/pandas/labels/Missing-data","name":"Missing-data","color":"d7e102"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-01-31T02:01:50Z","updated_at":"2016-05-24T15:35:04Z","closed_at":null,"body":"Currently, Pandas interpolation interpolates all gaps, regardless of there size and the limit parameter is used to limit the number of replacement :  if there is a gap of 3 values and limit=2, pandas replaces the first 2 values. \r\n\r\nI have difficulty understanding why someone would want to do interpolation on only a few missing items in a consecutive series of missing.\r\n\r\nPersonally, depending on the length of the gap, I would like to decide to interpolate the whole gap or none of it. For example, in an hourly time-series, interpolation of missing hours up to a maximum of 3 consecutive hours:\r\n gaps <= 3 would be interpolated\r\n gaps > 3 remain untouched.\r\n\r\nI would appreciated a option for interpolation such as R \"na.approx\" in which a \"maxgap\" parameters is available. maxgap:  maximum number of consecutive NAs to fill. Any longer gaps will be left unchanged. \r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/pydata/pandas/issues/comments/221310645","html_url":"https://github.com/pydata/pandas/issues/12187#issuecomment-221310645","issue_url":"https://api.github.com/repos/pydata/pandas/issues/12187","id":221310645,"user":{"login":"tomchor","id":13205162,"avatar_url":"https://avatars.githubusercontent.com/u/13205162?v=3","gravatar_id":"","url":"https://api.github.com/users/tomchor","html_url":"https://github.com/tomchor","followers_url":"https://api.github.com/users/tomchor/followers","following_url":"https://api.github.com/users/tomchor/following{/other_user}","gists_url":"https://api.github.com/users/tomchor/gists{/gist_id}","starred_url":"https://api.github.com/users/tomchor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomchor/subscriptions","organizations_url":"https://api.github.com/users/tomchor/orgs","repos_url":"https://api.github.com/users/tomchor/repos","events_url":"https://api.github.com/users/tomchor/events{/privacy}","received_events_url":"https://api.github.com/users/tomchor/received_events","type":"User","site_admin":false},"created_at":"2016-05-24T15:35:04Z","updated_at":"2016-05-24T15:35:04Z","body":"I've actually had to do something like this before. See [this answer](http://stackoverflow.com/questions/32850185/change-value-if-consecutive-number-of-certain-condition-is-achieved-in-pandas) to check out how it was achieved.\r\n\r\nI can actually say this is pretty useful. I know a number of quality-control techniques that use this kind of reasoning: if gap < maxgap do nothing, do something else otherwise (or vice-versa).\r\n\r\nI would recommend something like passing an extra `maxgap` and `mingap` keywords to interpolate, that control maximum number of consecutive gaps to consider when interpolating and the minimum. The OP's original example would become something like\r\n\r\n    interpolated = df.interpolate(maxgap=3, mingap=None)"}}
{"actor":{"display_login":"tomchor"}}