You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/source/computation.rst
+5-7Lines changed: 5 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -254,7 +254,7 @@ accept the following arguments:
254
254
255
255
The ``freq`` and ``how`` arguments were in the API prior to 0.18.0 changes. These are deprecated in the new API. You can simply resample the input prior to creating a window function.
256
256
257
-
For example, instead of ``s.rolling(window=5,freq='D').max()`` to get the max value on a rolling 5 Day window, one could use ``s.resample('D',how='max').rolling(window=5).max()``, which first resamples the data to daily data, then provides a rolling 5 day window.
257
+
For example, instead of ``s.rolling(window=5,freq='D').max()`` to get the max value on a rolling 5 Day window, one could use ``s.resample('D').max().rolling(window=5).max()``, which first resamples the data to daily data, then provides a rolling 5 day window.
258
258
259
259
We can then call methods on these ``rolling`` objects. These return like-indexed objects:
260
260
@@ -477,9 +477,7 @@ Aggregation
477
477
-----------
478
478
479
479
Once the ``Rolling``, ``Expanding`` or ``EWM`` objects have been created, several methods are available to
480
-
perform multiple computations on the data. This is very similar to a ``.groupby.agg`` seen :ref:`here <groupby.aggregate>`.
481
-
482
-
An obvious one is aggregation via the ``aggregate`` or equivalently ``agg`` method:
480
+
perform multiple computations on the data. This is very similar to a ``.groupby(...).agg`` seen :ref:`here <groupby.aggregate>`.
483
481
484
482
.. ipython:: python
485
483
@@ -545,7 +543,7 @@ columns of a DataFrame:
545
543
'B' : lambdax: np.std(x, ddof=1)})
546
544
547
545
The function names can also be strings. In order for a string to be valid it
548
-
must be implemented on the Windowed object
546
+
must be implemented on the windowed object
549
547
550
548
.. ipython:: python
551
549
@@ -647,7 +645,7 @@ Exponentially Weighted Windows
647
645
648
646
A related set of functions are exponentially weighted versions of several of
649
647
the above statistics. A similar interface to ``.rolling`` and ``.expanding`` is accessed
650
-
thru the ``.ewm`` method to receive a:class:`~pandas.core.window.EWM` object.
648
+
thru the ``.ewm`` method to receive an:class:`~pandas.core.window.EWM` object.
651
649
A number of expanding EW (exponentially weighted)
652
650
methods are provided:
653
651
@@ -806,5 +804,5 @@ are scaled by debiasing factors
806
804
807
805
(For :math:`w_i = 1`, this reduces to the usual :math:`N / (N - 1)` factor,
808
806
with :math:`N = t + 1`.)
809
-
See http://en.wikipedia.org/wiki/Weighted_arithmetic_mean#Weighted_sample_variance
807
+
See `Weighted Sample Variance <http://en.wikipedia.org/wiki/Weighted_arithmetic_mean#Weighted_sample_variance>`__
@@ -191,10 +191,17 @@ In v0.18.0, the ``expand`` argument was added to
191
191
192
192
Currently the default is ``expand=None`` which gives a ``FutureWarning`` and uses ``expand=False``. To avoid this warning, please explicitly specify ``expand``.
In [2]: pd.Series(['a','b',np.nan,'c']).str.cat(' ')
283
290
ValueError: Did you mean to supply a `sep` keyword?
284
291
285
292
@@ -327,21 +334,21 @@ In addition, ``.round()``, ``.floor()`` and ``.ceil()`` will be available thru t
327
334
328
335
.. ipython:: python
329
336
330
-
s = Series(dr)
337
+
s = pd.Series(dr)
331
338
s
332
339
s.dt.round('D')
333
340
334
-
Formatting of integer in FloatIndex
335
-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
341
+
Formatting of Integers in FloatIndex
342
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
336
343
337
344
Integers in ``FloatIndex``, e.g. 1., are now formatted with a decimal point and a ``0`` digit, e.g. ``1.0`` (:issue:`11713`)
338
-
This change not only affects the display in a jupyter notebook, but also the output of IO methods like ``.to_csv`` or ``.to_html``
345
+
This change not only affects the display to the console, but also the output of IO methods like ``.to_csv`` or ``.to_html``.
339
346
340
347
Previous Behavior:
341
348
342
349
.. code-block:: python
343
350
344
-
In [2]: s = Series([1,2,3], index=np.arange(3.))
351
+
In [2]: s = pd.Series([1,2,3], index=np.arange(3.))
345
352
346
353
In [3]: s
347
354
Out[3]:
@@ -363,7 +370,7 @@ New Behavior:
363
370
364
371
.. ipython:: python
365
372
366
-
s = Series([1,2,3], index=np.arange(3.))
373
+
s = pd.Series([1,2,3], index=np.arange(3.))
367
374
s
368
375
s.index
369
376
print(s.to_csv(path=None))
@@ -451,7 +458,7 @@ to_xarray
451
458
452
459
In a future version of pandas, we will be deprecating ``Panel`` and other > 2 ndim objects. In order to provide for continuity,
453
460
all ``NDFrame`` objects have gained the ``.to_xarray()`` method in order to convert to ``xarray`` objects, which has
454
-
a pandas-like interface for > 2 ndim.
461
+
a pandas-like interface for > 2 ndim. (:issue:`11972`)
455
462
456
463
See the `xarray full-documentation here <http://xarray.pydata.org/en/stable/>`__.
457
464
@@ -479,17 +486,17 @@ Latex Representation
479
486
480
487
``DataFrame`` has gained a ``._repr_latex_()`` method in order to allow for conversion to latex in a ipython/jupyter notebook using nbconvert. (:issue:`11778`)
481
488
482
-
Note that this must be activated by setting the option ``display.latex.repr`` to ``True`` (issue:`12182`)
489
+
Note that this must be activated by setting the option ``pd.display.latex.repr=True`` (:issue:`12182`)
483
490
484
-
For example, if you have a jupyter notebook you plan to convert to latex using nbconvert, place the statement ``pd.set_option('display.latex.repr', True)`` in the first cell to have the contained DataFrame output also stored as latex.
491
+
For example, if you have a jupyter notebook you plan to convert to latex using nbconvert, place the statement ``pd.display.latex.repr=True`` in the first cell to have the contained DataFrame output also stored as latex.
485
492
486
-
Options ``display.latex.escape`` and ``display.latex.longtable`` have also been added to the configuration and are used automatically by the ``to_latex``
487
-
method. See the :ref:`options documentation<options>` for more info.
493
+
The options ``display.latex.escape`` and ``display.latex.longtable`` have also been added to the configuration and are used automatically by the ``to_latex``
494
+
method. See the :ref:`available options docs <options.available>` for more info.
488
495
489
496
.. _whatsnew_0180.enhancements.sas:
490
497
491
-
read_sas changes
492
-
^^^^^^^^^^^^^^^^
498
+
``pd.read_sas()`` changes
499
+
^^^^^^^^^^^^^^^^^^^^^^^^^
493
500
494
501
``read_sas`` has gained the ability to read SAS7BDAT files, including compressed files. The files can be read in entirety, or incrementally. For full details see :ref:`here <io.sas>`. (:issue:`4052`)
495
502
@@ -736,7 +743,7 @@ You could also specify a ``how`` directly
@@ -747,7 +754,7 @@ You could also specify a ``how`` directly
747
754
748
755
**New API**:
749
756
750
-
Now, you can write ``.resample`` as a 2-stage operation like groupby, which
757
+
Now, you can write ``.resample(..)`` as a 2-stage operation like ``.groupby(...)``, which
751
758
yields a ``Resampler``.
752
759
753
760
.. ipython:: python
@@ -760,7 +767,7 @@ Downsampling
760
767
''''''''''''
761
768
762
769
You can then use this object to perform operations.
763
-
These are downsampling operations (going from a lower frequency to a higher one).
770
+
These are downsampling operations (going from a higher frequency to a lower one).
764
771
765
772
.. ipython:: python
766
773
@@ -793,7 +800,7 @@ Upsampling
793
800
794
801
.. currentmodule:: pandas.tseries.resample
795
802
796
-
Upsampling operations take you from a higher frequency to a lower frequency. These are now
803
+
Upsampling operations take you from a lower frequency to a higher frequency. These are now
797
804
performed with the ``Resampler`` objects with :meth:`~Resampler.backfill`,
798
805
:meth:`~Resampler.ffill`, :meth:`~Resampler.fillna` and :meth:`~Resampler.asfreq` methods.
799
806
@@ -834,8 +841,8 @@ New API
834
841
835
842
In the new API, you can either downsample OR upsample. The prior implementation would allow you to pass an aggregator function (like ``mean``) even though you were upsampling, providing a bit of confusion.
836
843
837
-
Previous API will work but deprecations
838
-
'''''''''''''''''''''''''''''''''''''''
844
+
Previous API will work but with deprecations
845
+
''''''''''''''''''''''''''''''''''''''''''''
839
846
840
847
.. warning::
841
848
@@ -887,6 +894,12 @@ Previous API will work but deprecations
887
894
The good news is the return dimensions will differ between the new API and the old API, so this should loudly raise
888
895
an exception.
889
896
897
+
To replicate the original operation
898
+
899
+
.. ipython:: python
900
+
901
+
df.resample('2s').mean().min()
902
+
890
903
Changes to eval
891
904
^^^^^^^^^^^^^^^
892
905
@@ -980,16 +993,16 @@ Other API Changes
980
993
In [2]: s.between_time('20150101 07:00:00','20150101 09:00:00')
981
994
ValueError: Cannot convert arg ['20150101 07:00:00'] to a time.
982
995
983
-
- ``.memory_usage()`` now includes values in the index, as does memory_usage in ``.info`` (:issue:`11597`)
984
-
- ``DataFrame.to_latex()`` now supports non-ascii encodings (eg utf-8) in Python 2 with the parameter ``encoding`` (:issue:`7061`)
996
+
- ``.memory_usage()`` now includes values in the index, as does memory_usage in ``.info()`` (:issue:`11597`)
997
+
- ``DataFrame.to_latex()`` now supports non-ascii encodings (eg ``utf-8``) in Python 2 with the parameter ``encoding`` (:issue:`7061`)
985
998
- ``pandas.merge()`` and ``DataFrame.merge()`` will show a specific error message when trying to merge with an object that is not of type ``DataFrame`` or a subclass (:issue:`12081`)
986
999
- ``DataFrame.unstack`` and ``Series.unstack`` now take ``fill_value`` keyword to allow direct replacement of missing values when an unstack results in missing values in the resulting ``DataFrame``. As an added benefit, specifying ``fill_value`` will preserve the data type of the original stacked data. (:issue:`9746`)
987
1000
- As part of the new API for :ref:`window functions <whatsnew_0180.enhancements.moments>` and :ref:`resampling <whatsnew_0180.breaking.resample>`, aggregation functions have been clarified, raising more informative error messages on invalid aggregations. (:issue:`9052`). A full set of examples are presented in :ref:`groupby <groupby.aggregate>`.
988
-
- Statistical functions for ``NDFrame`` objects will now raise if non-numpy-compatible arguments are passed in for ``**kwargs`` (:issue:`12301`)
1001
+
- Statistical functions for ``NDFrame`` objects (like ``sum(), mean(), min()``) will now raise if non-numpy-compatible arguments are passed in for ``**kwargs`` (:issue:`12301`)
989
1002
- ``.to_latex`` and ``.to_html`` gain a ``decimal`` parameter like ``.to_csv``; the default is ``'.'`` (:issue:`12031`)
990
1003
- More helpful error message when constructing a ``DataFrame`` with empty data but with indices (:issue:`8020`)
991
1004
- ``.describe()`` will now properly handle bool dtype as a categorical (:issue:`6625`)
992
-
- More helpful error message invalid ``.transform`` with user defined input (:issue:`10165`)
1005
+
- More helpful error message with an invalid ``.transform`` with user defined input (:issue:`10165`)
993
1006
- Exponentially weighted functions now allow specifying alpha directly (:issue:`10789`) and raise ``ValueError`` if parameters violate ``0 < alpha <= 1`` (:issue:`12492`)
994
1007
995
1008
.. _whatsnew_0180.deprecations:
@@ -1028,7 +1041,7 @@ Deprecations
1028
1041
1029
1042
- The the ``freq`` and ``how`` arguments to the ``.rolling``, ``.expanding``, and ``.ewm`` (new) functions are deprecated, and will be removed in a future version. You can simply resample the input prior to creating a window function. (:issue:`11603`).
1030
1043
1031
-
For example, instead of ``s.rolling(window=5,freq='D').max()`` to get the max value on a rolling 5 Day window, one could use ``s.resample('D',how='max').rolling(window=5).max()``, which first resamples the data to daily data, then provides a rolling 5 day window.
1044
+
For example, instead of ``s.rolling(window=5,freq='D').max()`` to get the max value on a rolling 5 Day window, one could use ``s.resample('D').mean().rolling(window=5).max()``, which first resamples the data to daily data, then provides a rolling 5 day window.
1032
1045
1033
1046
- ``pd.tseries.frequencies.get_offset_name`` function is deprecated. Use offset's ``.freqstr`` property as alternative (:issue:`11192`)
1034
1047
- ``pandas.stats.fama_macbeth`` routines are deprecated and will be removed in a future version (:issue:`6077`)
@@ -1118,6 +1131,13 @@ and setting
1118
1131
s_copy.ix[5.0] = 10
1119
1132
s_copy
1120
1133
1134
+
Positional setting with ``.ix`` and a float indexer will ADD this value to the index, rather than previously setting the value by position.
1135
+
1136
+
.. ipython:: python
1137
+
1138
+
s2.ix[1.0] = 10
1139
+
s2
1140
+
1121
1141
Slicing will also coerce integer-like floats to integers for a non-``Float64Index``.
0 commit comments