Skip to content

Commit

Permalink
TST: Verify that positional shifting works with duplicate columns (#9092
Browse files Browse the repository at this point in the history
)
  • Loading branch information
dsm054 committed Jul 1, 2017
1 parent b2b5dc3 commit a090024
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions pandas/tests/frame/test_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,27 @@ def test_shift_empty(self):

assert_frame_equal(df, rs)

def test_shift_duplicate_columns(self):
# GH 9092; verify that position-based shifting works
# in the presence of duplicate columns
column_lists = [list(range(5)), [1] * 5, [1, 1, 2, 2, 1]]
data = np.random.randn(20, 5)

shifted = []
for columns in column_lists:
df = pd.DataFrame(data.copy(), columns=columns)
for s in range(5):
df.iloc[:, s] = df.iloc[:, s].shift(s + 1)
df.columns = range(5)
shifted.append(df)

# sanity check the base case
nulls = shifted[0].isnull().sum()
assert_series_equal(nulls, Series(range(1, 6)))
# check all answers are the same
assert_frame_equal(shifted[0], shifted[1])
assert_frame_equal(shifted[0], shifted[2])

def test_tshift(self):
# PeriodIndex
ps = tm.makePeriodFrame()
Expand Down

0 comments on commit a090024

Please sign in to comment.