Skip to content
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

Don't sort columns for DataFrame init from list of Series #14136

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions python/cudf/cudf/core/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -7885,9 +7885,7 @@ def _get_union_of_indices(indexes):
return indexes[0]
else:
merged_index = cudf.core.index.GenericIndex._concat(indexes)
merged_index = merged_index.drop_duplicates()
inds = merged_index._values.argsort()
return merged_index.take(inds)
return merged_index.drop_duplicates()


def _get_union_of_series_names(series_list):
Expand Down
12 changes: 12 additions & 0 deletions python/cudf/cudf/tests/test_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,18 @@ def test_init_unaligned_with_index():
assert_eq(pdf, gdf, check_dtype=False)


def test_init_series_list_columns_unsort():
pseries = [
pd.Series(i, index=["b", "a", "c"], name=str(i)) for i in range(3)
]
gseries = [
cudf.Series(i, index=["b", "a", "c"], name=str(i)) for i in range(3)
]
pdf = pd.DataFrame(pseries)
gdf = cudf.DataFrame(gseries)
assert_eq(pdf, gdf)


def test_series_basic():
# Make series from buffer
a1 = np.arange(10, dtype=np.float64)
Expand Down