Skip to content

Commit aa969f8

Browse files
committed
Merge branch 'master' of https://github.com/pandas-dev/pandas into div_zero2
2 parents 000aefd + 35812ea commit aa969f8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+2096
-2783
lines changed

asv_bench/benchmarks/rolling.py

+23-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ class Methods(object):
1111
[10, 1000],
1212
['int', 'float'],
1313
['median', 'mean', 'max', 'min', 'std', 'count', 'skew', 'kurt',
14-
'sum', 'corr', 'cov'])
15-
param_names = ['constructor', 'window', 'dtype', 'method']
14+
'sum'])
15+
param_names = ['contructor', 'window', 'dtype', 'method']
1616

1717
def setup(self, constructor, window, dtype, method):
1818
N = 10**5
@@ -23,6 +23,27 @@ def time_rolling(self, constructor, window, dtype, method):
2323
getattr(self.roll, method)()
2424

2525

26+
class Pairwise(object):
27+
28+
sample_time = 0.2
29+
params = ([10, 1000, None],
30+
['corr', 'cov'],
31+
[True, False])
32+
param_names = ['window', 'method', 'pairwise']
33+
34+
def setup(self, window, method, pairwise):
35+
N = 10**4
36+
arr = np.random.random(N)
37+
self.df = pd.DataFrame(arr)
38+
39+
def time_pairwise(self, window, method, pairwise):
40+
if window is None:
41+
r = self.df.expanding()
42+
else:
43+
r = self.df.rolling(window=window)
44+
getattr(r, method)(self.df, pairwise=pairwise)
45+
46+
2647
class Quantile(object):
2748

2849
sample_time = 0.2

doc/source/categorical.rst

+99-88
Large diffs are not rendered by default.

doc/source/computation.rst

+2-9
Original file line numberDiff line numberDiff line change
@@ -209,19 +209,12 @@ Window Functions
209209

210210
.. currentmodule:: pandas.core.window
211211

212-
.. warning::
213-
214-
Prior to version 0.18.0, ``pd.rolling_*``, ``pd.expanding_*``, and ``pd.ewm*`` were module level
215-
functions and are now deprecated. These are replaced by using the :class:`~pandas.core.window.Rolling`, :class:`~pandas.core.window.Expanding` and :class:`~pandas.core.window.EWM`. objects and a corresponding method call.
216-
217-
The deprecation warning will show the new syntax, see an example :ref:`here <whatsnew_0180.window_deprecations>`.
218-
219-
For working with data, a number of windows functions are provided for
212+
For working with data, a number of window functions are provided for
220213
computing common *window* or *rolling* statistics. Among these are count, sum,
221214
mean, median, correlation, variance, covariance, standard deviation, skewness,
222215
and kurtosis.
223216

224-
Starting in version 0.18.1, the ``rolling()`` and ``expanding()``
217+
The ``rolling()`` and ``expanding()``
225218
functions can be used directly from DataFrameGroupBy objects,
226219
see the :ref:`groupby docs <groupby.transform.window_resample>`.
227220

doc/source/missing_data.rst

+39-14
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ Sum/Prod of Empties/Nans
190190
.. warning::
191191

192192
This behavior is now standard as of v0.21.0; previously sum/prod would give different
193-
results if the ``bottleneck`` package was installed.
193+
results if the ``bottleneck`` package was installed.
194194
See the :ref:`v0.21.0 whatsnew <whatsnew_0210.api_breaking.bottleneck>`.
195195

196196
With ``sum`` or ``prod`` on an empty or all-``NaN`` ``Series``, or columns of a ``DataFrame``, the result will be all-``NaN``.
@@ -353,7 +353,11 @@ examined :ref:`in the API <api.dataframe.missing>`.
353353
Interpolation
354354
~~~~~~~~~~~~~
355355

356-
Both Series and DataFrame objects have an :meth:`~DataFrame.interpolate` method
356+
.. versionadded:: 0.21.0
357+
358+
The ``limit_area`` keyword argument was added.
359+
360+
Both Series and DataFrame objects have an :meth:`~DataFrame.interpolate` method
357361
that, by default, performs linear interpolation at missing datapoints.
358362

359363
.. ipython:: python
@@ -477,33 +481,54 @@ at the new values.
477481
.. _documentation: http://docs.scipy.org/doc/scipy/reference/interpolate.html#univariate-interpolation
478482
.. _guide: http://docs.scipy.org/doc/scipy/reference/tutorial/interpolate.html
479483

484+
.. _missing_data.interp_limits:
485+
480486
Interpolation Limits
481487
^^^^^^^^^^^^^^^^^^^^
482488

483489
Like other pandas fill methods, ``interpolate`` accepts a ``limit`` keyword
484-
argument. Use this argument to limit the number of consecutive interpolations,
485-
keeping ``NaN`` values for interpolations that are too far from the last valid
486-
observation:
490+
argument. Use this argument to limit the number of consecutive ``NaN`` values
491+
filled since the last valid observation:
487492

488493
.. ipython:: python
489494
490-
ser = pd.Series([np.nan, np.nan, 5, np.nan, np.nan, np.nan, 13])
491-
ser.interpolate(limit=2)
495+
ser = pd.Series([np.nan, np.nan, 5, np.nan, np.nan, np.nan, 13, np.nan, np.nan])
492496
493-
By default, ``limit`` applies in a forward direction, so that only ``NaN``
494-
values after a non-``NaN`` value can be filled. If you provide ``'backward'`` or
495-
``'both'`` for the ``limit_direction`` keyword argument, you can fill ``NaN``
496-
values before non-``NaN`` values, or both before and after non-``NaN`` values,
497-
respectively:
497+
# fill all consecutive values in a forward direction
498+
ser.interpolate()
498499
499-
.. ipython:: python
500+
# fill one consecutive value in a forward direction
501+
ser.interpolate(limit=1)
502+
503+
By default, ``NaN`` values are filled in a ``forward`` direction. Use
504+
``limit_direction`` parameter to fill ``backward`` or from ``both`` directions.
500505

501-
ser.interpolate(limit=1) # limit_direction == 'forward'
506+
.. ipython:: python
502507
508+
# fill one consecutive value backwards
503509
ser.interpolate(limit=1, limit_direction='backward')
504510
511+
# fill one consecutive value in both directions
505512
ser.interpolate(limit=1, limit_direction='both')
506513
514+
# fill all consecutive values in both directions
515+
ser.interpolate(limit_direction='both')
516+
517+
By default, ``NaN`` values are filled whether they are inside (surrounded by)
518+
existing valid values, or outside existing valid values. Introduced in v0.23
519+
the ``limit_area`` parameter restricts filling to either inside or outside values.
520+
521+
.. ipython:: python
522+
523+
# fill one consecutive inside value in both directions
524+
ser.interpolate(limit_direction='both', limit_area='inside', limit=1)
525+
526+
# fill all consecutive outside values backward
527+
ser.interpolate(limit_direction='backward', limit_area='outside')
528+
529+
# fill all consecutive outside values in both directions
530+
ser.interpolate(limit_direction='both', limit_area='outside')
531+
507532
.. _missing_data.replace:
508533

509534
Replacing Generic Values

0 commit comments

Comments
 (0)