Skip to content

Commit 381b189

Browse files
authored
Regression tests to cover reset_index issue (#52741)
* add regression test to cover an issue #38147 * add assert to the tests * replace Index with RangeIndex
1 parent e09a193 commit 381b189

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pandas/tests/frame/methods/test_reset_index.py

+15
Original file line numberDiff line numberDiff line change
@@ -773,3 +773,18 @@ def test_errorreset_index_rename(float_frame):
773773

774774
with pytest.raises(IndexError, match="list index out of range"):
775775
stacked_df.reset_index(names=["new_first"])
776+
777+
778+
def test_reset_index_false_index_name():
779+
result_series = Series(data=range(5, 10), index=range(0, 5))
780+
result_series.index.name = False
781+
result_series.reset_index()
782+
expected_series = Series(range(5, 10), RangeIndex(range(0, 5), name=False))
783+
tm.assert_series_equal(result_series, expected_series)
784+
785+
# GH 38147
786+
result_frame = DataFrame(data=range(5, 10), index=range(0, 5))
787+
result_frame.index.name = False
788+
result_frame.reset_index()
789+
expected_frame = DataFrame(range(5, 10), RangeIndex(range(0, 5), name=False))
790+
tm.assert_frame_equal(result_frame, expected_frame)

0 commit comments

Comments
 (0)