-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Reindex with columns and method #14993
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -297,6 +297,35 @@ def test_reindex_columns(self): | |
newFrame = self.frame.reindex(columns=[]) | ||
self.assertTrue(newFrame.empty) | ||
|
||
# GH 14992, reindexing over columns ignored method | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can make it a new test |
||
df = DataFrame(data=[[11, 12, 13], [21, 22, 23], [31, 32, 33]], | ||
index=[1, 2, 4], | ||
columns=[1, 2, 4], | ||
dtype=float) | ||
expected_def = DataFrame(data=[[np.nan, 11, 12, np.nan, 13, np.nan], | ||
[np.nan, 21, 22, np.nan, 23, np.nan], | ||
[np.nan, 31, 32, np.nan, 33, np.nan]], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can just do these as:
easier to read this way |
||
index=[1, 2, 4], | ||
columns=range(6), | ||
dtype=float) | ||
expected_ffill = DataFrame(data=[[np.nan, 11, 12, 12, 13, 13], | ||
[np.nan, 21, 22, 22, 23, 23], | ||
[np.nan, 31, 32, 32, 33, 33]], | ||
index=[1, 2, 4], | ||
columns=range(6), | ||
dtype=float) | ||
expected_bfill = DataFrame(data=[[11, 11, 12, 13, 13, np.nan], | ||
[21, 21, 22, 23, 23, np.nan], | ||
[31, 31, 32, 33, 33, np.nan]], | ||
index=[1, 2, 4], | ||
columns=range(6), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add similar tests for sparse as well. |
||
dtype=float) | ||
assert_frame_equal(df.reindex(columns=range(6)), expected_def) | ||
assert_frame_equal(df.reindex(columns=range(6), method='ffill'), | ||
expected_ffill) | ||
assert_frame_equal(df.reindex(columns=range(6), method='bfill'), | ||
expected_bfill) | ||
|
||
def test_reindex_axes(self): | ||
# GH 3317, reindexing by both axes loses freq of the index | ||
df = DataFrame(np.ones((3, 3)), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
say that when passing
columns
,method
was ignored.