Skip to content

Commit 4b3410f

Browse files
committed
Merge branch 'master' of github.com:pydata/pandas
2 parents 45ae832 + ce01bd9 commit 4b3410f

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

doc/source/timeseries.rst

+1-2
Original file line numberDiff line numberDiff line change
@@ -1010,8 +1010,7 @@ Shifting / lagging
10101010

10111011
One may want to *shift* or *lag* the values in a TimeSeries back and forward in
10121012
time. The method for this is ``shift``, which is available on all of the pandas
1013-
objects. In DataFrame, ``shift`` will currently only shift along the ``index``
1014-
and in Panel along the ``major_axis``.
1013+
objects.
10151014

10161015
.. ipython:: python
10171016

pandas/core/frame.py

+5
Original file line numberDiff line numberDiff line change
@@ -2525,6 +2525,11 @@ def fillna(self, value=None, method=None, axis=None, inplace=False,
25252525
limit=limit, downcast=downcast,
25262526
**kwargs)
25272527

2528+
@Appender(_shared_docs['shift'] % _shared_doc_kwargs)
2529+
def shift(self, periods=1, freq=None, axis=0, **kwargs):
2530+
return super(DataFrame, self).shift(periods=periods, freq=freq,
2531+
axis=axis, **kwargs)
2532+
25282533
def set_index(self, keys, drop=True, append=False, inplace=False,
25292534
verify_integrity=False):
25302535
"""

pandas/core/generic.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -3584,8 +3584,7 @@ def mask(self, cond, other=np.nan, inplace=False, axis=None, level=None,
35843584
return self.where(~cond, other=other, inplace=inplace, axis=axis,
35853585
level=level, try_cast=try_cast, raise_on_error=raise_on_error)
35863586

3587-
def shift(self, periods=1, freq=None, axis=0, **kwargs):
3588-
"""
3587+
_shared_docs['shift'] = ("""
35893588
Shift index by desired number of periods with an optional time freq
35903589
35913590
Parameters
@@ -3595,6 +3594,7 @@ def shift(self, periods=1, freq=None, axis=0, **kwargs):
35953594
freq : DateOffset, timedelta, or time rule string, optional
35963595
Increment to use from datetools module or time rule (e.g. 'EOM').
35973596
See Notes.
3597+
axis : %(axes_single_arg)s
35983598
35993599
Notes
36003600
-----
@@ -3604,8 +3604,10 @@ def shift(self, periods=1, freq=None, axis=0, **kwargs):
36043604
36053605
Returns
36063606
-------
3607-
shifted : same type as caller
3608-
"""
3607+
shifted : %(klass)s
3608+
""")
3609+
@Appender(_shared_docs['shift'] % _shared_doc_kwargs)
3610+
def shift(self, periods=1, freq=None, axis=0, **kwargs):
36093611
if periods == 0:
36103612
return self
36113613

pandas/core/series.py

+5
Original file line numberDiff line numberDiff line change
@@ -2151,6 +2151,11 @@ def fillna(self, value=None, method=None, axis=None, inplace=False,
21512151
limit=limit, downcast=downcast,
21522152
**kwargs)
21532153

2154+
@Appender(generic._shared_docs['shift'] % _shared_doc_kwargs)
2155+
def shift(self, periods=1, freq=None, axis=0, **kwargs):
2156+
return super(Series, self).shift(periods=periods, freq=freq,
2157+
axis=axis, **kwargs)
2158+
21542159
def reindex_axis(self, labels, axis=0, **kwargs):
21552160
""" for compatibility with higher dims """
21562161
if axis != 0:

0 commit comments

Comments
 (0)