Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/pandas-dev/pandas into di…
Browse files Browse the repository at this point in the history
…v_zero2
  • Loading branch information
jbrockmendel committed Feb 1, 2018
2 parents 000aefd + 35812ea commit aa969f8
Show file tree
Hide file tree
Showing 69 changed files with 2,096 additions and 2,783 deletions.
25 changes: 23 additions & 2 deletions asv_bench/benchmarks/rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class Methods(object):
[10, 1000],
['int', 'float'],
['median', 'mean', 'max', 'min', 'std', 'count', 'skew', 'kurt',
'sum', 'corr', 'cov'])
param_names = ['constructor', 'window', 'dtype', 'method']
'sum'])
param_names = ['contructor', 'window', 'dtype', 'method']

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


class Pairwise(object):

sample_time = 0.2
params = ([10, 1000, None],
['corr', 'cov'],
[True, False])
param_names = ['window', 'method', 'pairwise']

def setup(self, window, method, pairwise):
N = 10**4
arr = np.random.random(N)
self.df = pd.DataFrame(arr)

def time_pairwise(self, window, method, pairwise):
if window is None:
r = self.df.expanding()
else:
r = self.df.rolling(window=window)
getattr(r, method)(self.df, pairwise=pairwise)


class Quantile(object):

sample_time = 0.2
Expand Down
187 changes: 99 additions & 88 deletions doc/source/categorical.rst

Large diffs are not rendered by default.

11 changes: 2 additions & 9 deletions doc/source/computation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -209,19 +209,12 @@ Window Functions

.. currentmodule:: pandas.core.window

.. warning::

Prior to version 0.18.0, ``pd.rolling_*``, ``pd.expanding_*``, and ``pd.ewm*`` were module level
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.

The deprecation warning will show the new syntax, see an example :ref:`here <whatsnew_0180.window_deprecations>`.

For working with data, a number of windows functions are provided for
For working with data, a number of window functions are provided for
computing common *window* or *rolling* statistics. Among these are count, sum,
mean, median, correlation, variance, covariance, standard deviation, skewness,
and kurtosis.

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

Expand Down
53 changes: 39 additions & 14 deletions doc/source/missing_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ Sum/Prod of Empties/Nans
.. warning::

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

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

Both Series and DataFrame objects have an :meth:`~DataFrame.interpolate` method
.. versionadded:: 0.21.0

The ``limit_area`` keyword argument was added.

Both Series and DataFrame objects have an :meth:`~DataFrame.interpolate` method
that, by default, performs linear interpolation at missing datapoints.

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

.. _missing_data.interp_limits:

Interpolation Limits
^^^^^^^^^^^^^^^^^^^^

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

.. ipython:: python
ser = pd.Series([np.nan, np.nan, 5, np.nan, np.nan, np.nan, 13])
ser.interpolate(limit=2)
ser = pd.Series([np.nan, np.nan, 5, np.nan, np.nan, np.nan, 13, np.nan, np.nan])
By default, ``limit`` applies in a forward direction, so that only ``NaN``
values after a non-``NaN`` value can be filled. If you provide ``'backward'`` or
``'both'`` for the ``limit_direction`` keyword argument, you can fill ``NaN``
values before non-``NaN`` values, or both before and after non-``NaN`` values,
respectively:
# fill all consecutive values in a forward direction
ser.interpolate()
.. ipython:: python
# fill one consecutive value in a forward direction
ser.interpolate(limit=1)
By default, ``NaN`` values are filled in a ``forward`` direction. Use
``limit_direction`` parameter to fill ``backward`` or from ``both`` directions.

ser.interpolate(limit=1) # limit_direction == 'forward'
.. ipython:: python
# fill one consecutive value backwards
ser.interpolate(limit=1, limit_direction='backward')
# fill one consecutive value in both directions
ser.interpolate(limit=1, limit_direction='both')
# fill all consecutive values in both directions
ser.interpolate(limit_direction='both')
By default, ``NaN`` values are filled whether they are inside (surrounded by)
existing valid values, or outside existing valid values. Introduced in v0.23
the ``limit_area`` parameter restricts filling to either inside or outside values.

.. ipython:: python
# fill one consecutive inside value in both directions
ser.interpolate(limit_direction='both', limit_area='inside', limit=1)
# fill all consecutive outside values backward
ser.interpolate(limit_direction='backward', limit_area='outside')
# fill all consecutive outside values in both directions
ser.interpolate(limit_direction='both', limit_area='outside')
.. _missing_data.replace:

Replacing Generic Values
Expand Down
Loading

0 comments on commit aa969f8

Please sign in to comment.