ENH: interpolate.limit_area() 16284
State: closed

 - [x] closes #16284
 - [x] tests added / passed
 - [x] passes ``git diff upstream/master --name-only -- '*.py' | flake8 --diff``
 - [x] whatsnew entry


Labels:
name: Enhancement
name: Missing-data
description: np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16513?src=pr&el=h1) Report
> Merging [#16513](https://codecov.io/gh/pandas-dev/pandas/pull/16513?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/75c8698e32432d7dd075a93933749a26c53b3029?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/16513/graphs/tree.svg?src=pr&token=eZ4WkYLtcO&width=650&height=150)](https://codecov.io/gh/pandas-dev/pandas/pull/16513?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #16513      +/-   ##
==========================================
+ Coverage   90.79%   90.79%   +<.01%     
==========================================
  Files         161      161              
  Lines       51063    51074      +11     
==========================================
+ Hits        46364    46375      +11     
  Misses       4699     4699
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.64% <100%> (ø)` | :arrow_up: |
| #single | `40.14% <0%> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/16513?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/16513?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ2VuZXJpYy5weQ==) | `92.26% <ø> (ø)` | :arrow_up: |
| [pandas/core/resample.py](https://codecov.io/gh/pandas-dev/pandas/pull/16513?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvcmVzYW1wbGUucHk=) | `96.09% <ø> (ø)` | :arrow_up: |
| [pandas/core/internals.py](https://codecov.io/gh/pandas-dev/pandas/pull/16513?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzLnB5) | `93.44% <ø> (ø)` | :arrow_up: |
| [pandas/core/missing.py](https://codecov.io/gh/pandas-dev/pandas/pull/16513?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvbWlzc2luZy5weQ==) | `84.8% <100%> (+0.52%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16513?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16513?src=pr&el=footer). Last update [75c8698...80d67b7](https://codecov.io/gh/pandas-dev/pandas/pull/16513?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16513?src=pr&el=h1) Report
> Merging [#16513](https://codecov.io/gh/pandas-dev/pandas/pull/16513?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/b4662cd9cbcc81f7d55ab15323d8227b8b0803b2?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/16513/graphs/tree.svg?src=pr&width=650&token=eZ4WkYLtcO&height=150)](https://codecov.io/gh/pandas-dev/pandas/pull/16513?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #16513      +/-   ##
==========================================
+ Coverage   91.57%   91.57%   +<.01%     
==========================================
  Files         150      150              
  Lines       48684    48695      +11     
==========================================
+ Hits        44583    44594      +11     
  Misses       4101     4101
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.94% <100%> (ø)` | :arrow_up: |
| #single | `41.71% <0%> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/16513?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/resample.py](https://codecov.io/gh/pandas-dev/pandas/pull/16513/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvcmVzYW1wbGUucHk=) | `96.43% <ø> (ø)` | :arrow_up: |
| [pandas/core/internals.py](https://codecov.io/gh/pandas-dev/pandas/pull/16513/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzLnB5) | `95.46% <ø> (ø)` | :arrow_up: |
| [pandas/core/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/16513/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ2VuZXJpYy5weQ==) | `95.91% <ø> (ø)` | :arrow_up: |
| [pandas/core/missing.py](https://codecov.io/gh/pandas-dev/pandas/pull/16513/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvbWlzc2luZy5weQ==) | `84.78% <100%> (+0.48%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16513?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16513?src=pr&el=footer). Last update [b4662cd...596f145](https://codecov.io/gh/pandas-dev/pandas/pull/16513?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

Hi Guys,

Looks like I got 7 tests failed, but they are not related to my code (as far as I can tell).

I see that we have some other active issues on testing right now, but I'm not sure if this issue is knows.

Do I need to do something about this?

Thanks.

XFAIL pandas/tests/test_window.py::TestExpanding::()::tests_empty_df_expanding[1s]
  GH 16425 expanding with offset not supported
XFAIL pandas/tests/frame/test_analytics.py::TestDataFrameAnalytics::()::test_clip_mixed_numeric
  clip on mixed integer or floats with integer clippers coerces to float
XFAIL pandas/tests/indexes/test_interval.py::TestIntervalIndex::()::test_repr
  not a valid repr as we use interval notation
XFAIL pandas/tests/indexes/test_interval.py::TestIntervalIndex::()::test_repr_max_seq_item_setting
  not a valid repr as we use interval notation
XFAIL pandas/tests/indexes/test_interval.py::TestIntervalIndex::()::test_repr_roundtrip
  not a valid repr as we use interval notation
XFAIL pandas/tests/io/test_excel.py::test_styler_to_excel[xlwt]
  xlwt does not support openpyxl-compatible style dicts
XFAIL pandas/tests/io/test_excel.py::test_styler_to_excel[openpyxl]
  reason: openpyxl1 does not support some openpyxl2-compatible style dicts

@WBare those are expected failures (x=expected). Nothing to worry about.

I'll review more thoroughly later, but at a glance I think this is a good approach.
Sounds good, @TomAugspurger .  I see you just did a giant backport, so I know you have your hands full.  Let me know if you need anything else on this.
I've committed the changes requested by @jreback , and we are back to green except the expected failures.

Ready for further review.

Thanks.
Looks like there's a conflict in `pandas/core/missing.py`. Mind rebasing? Sorry I couldn't get to this earlier.
> isn't limit_area essentially the difference between interpolate and extrapolate?

Essentially. I initially wanted a boolean `extrapolate` would would be like

- `extraploate=True` is like `limit_area=None`
- `extrapolate=False` is like `limit_area='inside'`

I think `limit_area` is fine, since it's more consistent with the other `limit_` keywords, it has the option to only extrapolate (not sure why you would want to do that, personally, but w/e), and this allows you to pass `extrapolate` through to the scipy methods if you're using though, which has a bit more powerful / different behavior. 
if you can rebase and update for comments
can you rebase / update according to comments


can you rebase. this looked pretty good.
@WBare can you rebase this.
can you rebase and we can finally get this in!
@WBare can you rebase / update.

note that #8000 might be related here.
can you rebase / update
@TomAugspurger I rebased. prob needs a once over if you can.
also haven't addressed @jorisvandenbossche comments yet.
closed by 35812eaaecebeeee0ddf07dee4b583c4eea07785