Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
expand tests
  • Loading branch information
chris-b1 committed Jan 1, 2017
commit 28bc8b430cbdadce7f231d7b79b190cdc1a639d1
10 changes: 7 additions & 3 deletions pandas/tests/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1509,13 +1509,14 @@ def test_rename_list_like(self):
df = pd.DataFrame({'a': [1, 2], 'b': [3, 4]}, columns=['a', 'b'])

expected = df.copy()
result = df.rename(columns=['J', 'K'])
expected.columns = ['J', 'K']
result = df.rename(columns=['J', 'K'])
assert_frame_equal(result, expected)

result = df.rename(columns=['J', 'K'], index=['a', 'b'])
expected.index = ['a', 'b']
assert_frame_equal(result, expected)
for box in [list, np.array, Index]:
result = df.rename(columns=box(['J', 'K']), index=box(['a', 'b']))
assert_frame_equal(result, expected)

result = df.copy()
result.rename(columns=['J', 'K'], index=['a', 'b'], inplace=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test with ndarray and with an Index
a scalar should error yes?

Expand All @@ -1524,6 +1525,9 @@ def test_rename_list_like(self):
with tm.assertRaises(ValueError):
df.rename(index=[1, 3, 3])

with tm.assertRaises(TypeError):
df.rename(index=1)


class TestPanel(tm.TestCase, Generic):
_typ = Panel
Expand Down