-
Notifications
You must be signed in to change notification settings - Fork 358
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
Add sort parameter to concat. #1636
Conversation
This is based on #1627. Please review it first. |
@@ -1834,9 +1843,11 @@ def resolve_func(kdf, this_column_labels, that_column_labels): | |||
# DataFrame, Series ... & Series, Series ... |
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.
Maybe we should throw an exception when axis=1
and sort
is set:
>>> import pandas as pd
>>> pd.concat([pd.DataFrame({'b': [4, 5, 6]}, index=[4,3,2]), pd.DataFrame({'a': [3, 4, 5]}, index=[4,3,2])], sort=False, axis=1)
b a
4 4 3
3 5 4
2 6 5
>>> pd.concat([pd.DataFrame({'b': [4, 5, 6]}, index=[4,3,2]), pd.DataFrame({'a': [3, 4, 5]}, index=[4,3,2])], sort=True, axis=1)
b a
2 6 5
3 5 4
4 4 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.
or do sort_index()
?
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.
Anyway pandas' behavior is not deterministic, at least seems so..
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.
😭 .. any way is fine. We could just sort_index()
or just throw an exception
databricks/koalas/namespace.py
Outdated
merged_columns = sorted( | ||
list(set(itertools.chain.from_iterable(column_labelses_of_kdfs))) | ||
) | ||
merged_columns = column_labels_of_kdfs[0].copy() |
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.
no big deal since it's already guarded above but we could add an assert
for the length of column_labels_of_kdfs
to be non-empty.
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.
We could also add an assert on merged_columns
too.
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.
LGTM
Thanks! merging. |
Adding
sort
parameter toks.concat()
.