Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix: Fix a bug that raises exception when re-indexing columns with th… #988

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

Merged
merged 2 commits into from
Sep 13, 2024
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
5 changes: 5 additions & 0 deletions 5 bigframes/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1913,6 +1913,11 @@ def _reindex_rows(
def _reindex_columns(self, columns):
block = self._block
new_column_index, indexer = self.columns.reindex(columns)

if indexer is None:
# The new index is the same as the old one. Do nothing.
return self

result_cols = []
for label, index in zip(columns, indexer):
if index >= 0:
Expand Down
15 changes: 15 additions & 0 deletions 15 tests/system/small/test_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -3664,6 +3664,21 @@ def test_df_reindex_columns(scalars_df_index, scalars_pandas_df_index):
)


def test_df_reindex_columns_with_same_order(scalars_df_index, scalars_pandas_df_index):
# First, make sure the two dataframes have the same columns in order.
columns = ["int64_col", "int64_too"]
bf = scalars_df_index[columns]
pd_df = scalars_pandas_df_index[columns]

bf_result = bf.reindex(columns=columns).to_pandas()
pd_result = pd_df.reindex(columns=columns)

pd.testing.assert_frame_equal(
bf_result,
pd_result,
)


def test_df_equals_identical(scalars_df_index, scalars_pandas_df_index):
unsupported = [
"geography_col",
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.