We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 010ed74 commit 9ecaf66Copy full SHA for 9ecaf66
pandas/core/frame.py
@@ -5706,12 +5706,10 @@ def shift(
5706
)
5707
5708
if self.empty:
5709
- self["__temp_column__"] = None
5710
- shifted_self = super().shift(
5711
- periods=periods, freq=freq, axis=axis, fill_value=fill_value
5712
- )
5713
- shifted_self.drop("__temp_column__", axis=1, inplace=True)
5714
- return shifted_self
+ if axis == 1:
+ return DataFrame(index=self.index, columns=self.columns.shift(periods))
+ else:
+ return DataFrame(index=self.index.shift(periods), columns=self.columns)
5715
5716
axis = self._get_axis_number(axis)
5717
0 commit comments