Skip to content

Commit 2973996

Browse files
code sample for pandas-dev#47039
1 parent f3ed08d commit 2973996

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

bisect/47039.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# BUG: DataFrame.shift shows different behavior for axis=1 when freq is specified #47039
2+
3+
import numpy as np
4+
import pandas as pd
5+
6+
print(pd.__version__)
7+
8+
rs = np.random.RandomState(0)
9+
10+
raw = pd.DataFrame(
11+
rs.randint(1000, size=(10, 8)), columns=["col" + str(i + 1) for i in range(8)]
12+
)
13+
raw.index = pd.date_range("2020-1-1", periods=10)
14+
raw.columns = pd.date_range("2020-3-1", periods=8)
15+
result = raw.shift(periods=2, freq="D", axis=1)
16+
print(result)
17+
18+
expected = raw.shift(periods=2, freq="D", axis=1, fill_value=0)
19+
pd.testing.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)