Make Series.shift always a copy? · Issue #22397 · pandas-dev/pandas (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Description
Right now, Series.shift(0)
will just return the series. Shifting for all other periods induces a copy:
In [1]: import pandas as pd
In [2]: a = pd.Series([1, 2])
In [3]: a.shift(1) is a Out[3]: False
In [4]: a.shift(0) is a Out[4]: True
Should we defensively copy on 0
as well, for a consistent user experience?
def shift(self, periods=1, freq=None, axis=0): |
---|
if periods == 0: |
return self |