Skip to content

Commit 53f3700

Browse files
committed
Account for index name
1 parent 28502ff commit 53f3700

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

pandas/io/parquet.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,10 @@ def read(
265265
elif len(index_columns) == 1 and isinstance(index_columns[0], dict):
266266
params = index_columns[0]
267267
idx = RangeIndex(
268-
params.get("start"), params.get("stop"), params.get("step")
268+
params.get("start"),
269+
params.get("stop"),
270+
params.get("step"),
271+
name=params.get("name"),
269272
)
270273

271274
else:

pandas/tests/io/test_parquet.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,11 +1241,13 @@ def test_pyarrow_backed_df_index(self, index, pa):
12411241
expected = obj.astype("int64[pyarrow]").set_index(index)
12421242
tm.assert_frame_equal(result, expected)
12431243

1244+
@pytest.mark.parametrize("name", [None, "test"])
12441245
@pytest.mark.parametrize("index", [True, False, None])
1245-
def test_pyarrow_backed_df_range_index(self, pa, index):
1246+
def test_pyarrow_backed_df_range_index(self, pa, index, name):
12461247
# GH#48944
12471248
df = pd.DataFrame(
1248-
data={"A": [0, 1], "B": [1, 0]}, index=RangeIndex(start=100, stop=102)
1249+
data={"A": [0, 1], "B": [1, 0]},
1250+
index=RangeIndex(start=100, stop=102, name=name),
12491251
)
12501252
with tm.ensure_clean("test.parquet") as path:
12511253
with open(path.encode(), "wb") as f:
@@ -1257,5 +1259,5 @@ def test_pyarrow_backed_df_range_index(self, pa, index):
12571259
if index is False:
12581260
expected = expected.reset_index(drop=True)
12591261
elif index:
1260-
expected.index = pd.Index([100, 101], dtype="int64[pyarrow]")
1262+
expected.index = pd.Index([100, 101], dtype="int64[pyarrow]", name=name)
12611263
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)