Skip to content
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
2 changes: 1 addition & 1 deletion bigframes/core/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ def reset_index(
A new Block because dropping index columns can break references
from Index classes that point to this block.
"""
if level:
if level is not None:
# preserve original order, not user provided order
level_ids: Sequence[str] = [
id for id in self.index_columns if id in self.index.resolve_level(level)
Expand Down
2 changes: 1 addition & 1 deletion bigframes/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -2577,7 +2577,7 @@ def reset_index(
names: Union[None, Hashable, Sequence[Hashable]] = None,
) -> Optional[DataFrame]:
block = self._block
if names:
if names is not None:
if isinstance(names, blocks.Label) and not isinstance(names, tuple):
names = [names]
else:
Expand Down
3 changes: 2 additions & 1 deletion tests/system/small/test_multiindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def test_set_multi_index(scalars_df_index, scalars_pandas_df_index):
("bool_col", True),
(["float64_col", "int64_too"], True),
([2, 0], False),
(0, True),
],
)
def test_df_reset_multi_index(scalars_df_index, scalars_pandas_df_index, level, drop):
Expand All @@ -124,7 +125,7 @@ def test_df_reset_multi_index(scalars_df_index, scalars_pandas_df_index, level,

# Pandas uses int64 instead of Int64 (nullable) dtype.
if pd_result.index.dtype != bf_result.index.dtype:
pd_result.index = pd_result.index.astype(pandas.Int64Dtype())
pd_result.index = pd_result.index.astype(bf_result.index.dtype)

pandas.testing.assert_frame_equal(bf_result, pd_result)

Expand Down