Skip to content

Commit

Permalink
Regression tests to cover reset_index issue (#52741)
Browse files Browse the repository at this point in the history
* add regression test to cover an issue #38147

* add assert to the tests

* replace Index with RangeIndex
  • Loading branch information
vagechirkov authored Apr 20, 2023
1 parent e09a193 commit 381b189
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pandas/tests/frame/methods/test_reset_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,3 +773,18 @@ def test_errorreset_index_rename(float_frame):

with pytest.raises(IndexError, match="list index out of range"):
stacked_df.reset_index(names=["new_first"])


def test_reset_index_false_index_name():
result_series = Series(data=range(5, 10), index=range(0, 5))
result_series.index.name = False
result_series.reset_index()
expected_series = Series(range(5, 10), RangeIndex(range(0, 5), name=False))
tm.assert_series_equal(result_series, expected_series)

# GH 38147
result_frame = DataFrame(data=range(5, 10), index=range(0, 5))
result_frame.index.name = False
result_frame.reset_index()
expected_frame = DataFrame(range(5, 10), RangeIndex(range(0, 5), name=False))
tm.assert_frame_equal(result_frame, expected_frame)

0 comments on commit 381b189

Please sign in to comment.