-
Notifications
You must be signed in to change notification settings - Fork 173
[ENH] add preserve_position kwarg to deconcatenate_column #478 #484
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 all commits
b0b3d32
57dd52a
95fe6c8
0d10ae7
b8a5c2f
2858d16
ec5128e
c76dc69
22975ad
5ef0f6b
5c51caf
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import pytest | ||
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. I’m so sorry, I should have made this clearer in the docs. This test should be in 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. Oops, sorry about that! (now I know what to do if similar situations are to happen in future). Thanks a lot! |
||
|
||
|
||
@pytest.mark.functions | ||
def test_deconcatenate_column_preserve_position(dataframe): | ||
df_original = dataframe.concatenate_columns( | ||
column_names=["a", "decorated-elephant"], | ||
sep="-", | ||
new_column_name="index", | ||
) | ||
index_original = list(df_original.columns).index("index") | ||
df = df_original.deconcatenate_column( | ||
column_name="index", | ||
new_column_names=["col1", "col2"], | ||
sep="-", | ||
preserve_position=True, | ||
) | ||
assert "index" not in df.columns, "column_name not dropped" | ||
assert "col1" in df.columns, "new column not present" | ||
assert "col2" in df.columns, "new column not present" | ||
assert len(df_original.columns) + 1 == len( | ||
df.columns | ||
), "Number of columns inconsistent" | ||
assert ( | ||
list(df.columns).index("col1") == index_original | ||
), "Position not preserved" | ||
assert ( | ||
list(df.columns).index("col2") == index_original + 1 | ||
), "Position not preserved" |
Uh oh!
There was an error while loading. Please reload this page.