@@ -6815,26 +6815,26 @@ def mask(self, cond, other=np.nan, inplace=False, axis=None, level=None,
6815
6815
errors = errors )
6816
6816
6817
6817
_shared_docs ['shift' ] = ("""
6818
- Shift index by desired number of periods with an optional time freq.
6818
+ Shift index by desired number of periods with an optional time ` freq` .
6819
6819
6820
- When freq is not passed, shift the index without realign the data.
6821
- If freq is passed (in this case, the index must be date or datetime),
6822
- the index will be increased using the periods and the freq.
6820
+ When ` freq` is not passed, shift the index without realigning the data.
6821
+ If ` freq` is passed (in this case, the index must be date or datetime),
6822
+ the index will be increased using the periods and the ` freq` .
6823
6823
6824
6824
Parameters
6825
6825
----------
6826
6826
periods : int
6827
- Number of periods to move, can be positive or negative.
6827
+ Number of periods to shift; can be positive or negative.
6828
6828
freq : DateOffset, timedelta, or time rule string, optional
6829
6829
Increment to use from the tseries module or time rule (e.g. 'EOM').
6830
6830
See Notes.
6831
- axis : int or str
6832
- Shift direction. %(axes_single_arg)s.
6831
+ axis : {0 or ‘index’, 1 or ‘columns’, None}, default None
6832
+ Shift direction.
6833
6833
6834
6834
Notes
6835
6835
-----
6836
- If freq is specified then the index values are shifted but the data
6837
- is not realigned. That is, use freq if you would like to extend the
6836
+ If ` freq` is specified then the index values are shifted but the data
6837
+ is not realigned. That is, use ` freq` if you would like to extend the
6838
6838
index when shifting and preserve the original data.
6839
6839
6840
6840
Returns
@@ -6843,18 +6843,9 @@ def mask(self, cond, other=np.nan, inplace=False, axis=None, level=None,
6843
6843
6844
6844
Examples
6845
6845
--------
6846
- >>> df = pd.DataFrame({'Col1': [10, 20, 30, 20, 15, 30, 45],
6847
- ... 'Col2': [13, 23, 33, 23, 18, 33, 48],
6848
- ... 'Col3': [17, 27, 37, 27, 22, 37, 52]})
6849
- >>> print(df)
6850
- Col1 Col2 Col3
6851
- 0 10 13 17
6852
- 1 20 23 27
6853
- 2 30 33 37
6854
- 3 20 23 27
6855
- 4 15 18 22
6856
- 5 30 33 37
6857
- 6 45 48 52
6846
+ >>> df = pd.DataFrame({'Col1': [10, 20, 15, 30, 45],
6847
+ ... 'Col2': [13, 23, 18, 33, 48],
6848
+ ... 'Col3': [17, 27, 22, 37, 52]})
6858
6849
6859
6850
>>> df.shift(periods=3)
6860
6851
Col1 Col2 Col3
@@ -6863,18 +6854,14 @@ def mask(self, cond, other=np.nan, inplace=False, axis=None, level=None,
6863
6854
2 NaN NaN NaN
6864
6855
3 10.0 13.0 17.0
6865
6856
4 20.0 23.0 27.0
6866
- 5 30.0 33.0 37.0
6867
- 6 20.0 23.0 27.0
6868
6857
6869
6858
>>> df.shift(periods=1, axis=1)
6870
6859
Col1 Col2 Col3
6871
6860
0 NaN 10.0 13.0
6872
6861
1 NaN 20.0 23.0
6873
- 2 NaN 30.0 33.0
6874
- 3 NaN 20.0 23.0
6875
- 4 NaN 15.0 18.0
6876
- 5 NaN 30.0 33.0
6877
- 6 NaN 45.0 48.0
6862
+ 2 NaN 15.0 18.0
6863
+ 3 NaN 30.0 33.0
6864
+ 4 NaN 45.0 48.0
6878
6865
6879
6866
>>> import datetime
6880
6867
>>> names = ['João', 'Maria', 'Emanuel', 'Jussara', 'José']
@@ -6884,7 +6871,7 @@ def mask(self, cond, other=np.nan, inplace=False, axis=None, level=None,
6884
6871
... datetime.datetime(2018, 3, 15, 11, 15),
6885
6872
... datetime.datetime(2018, 3, 20, 11, 15)]
6886
6873
>>> df = pd.DataFrame(data={'names': names}, index=dates)
6887
- >>> print(df)
6874
+ >>> df
6888
6875
names
6889
6876
2018-03-01 11:15:00 João
6890
6877
2018-03-05 11:15:00 Maria
@@ -6910,8 +6897,8 @@ def mask(self, cond, other=np.nan, inplace=False, axis=None, level=None,
6910
6897
6911
6898
See Also
6912
6899
--------
6913
- slice_shift: Equivalent to shift without copying data.
6914
- tshift: Shift the time index, using the index’s frequency if available.
6900
+ tshift : Shift the time index, using the index’s frequency if
6901
+ available.
6915
6902
""" )
6916
6903
6917
6904
@Appender (_shared_docs ['shift' ] % _shared_doc_kwargs )
0 commit comments