Skip to content

Commit eeed100

Browse files
committed
add test
1 parent fba0b02 commit eeed100

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/nested_pandas/nestedframe/test_nestedframe.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2205,6 +2205,17 @@ def test_nestlists_nonunique_index():
22052205
assert nf_repacked.equals(nf)
22062206

22072207

2208+
def test_nestlists_preserve_index_name():
2209+
"""Test that nest_lists preserves the index name with empty dataframes."""
2210+
2211+
# See https://github.com/lincc-frameworks/nested-pandas/issues/409 for context
2212+
nf = generate_data(5, 10, seed=1)
2213+
nf.index.name = "objectid"
2214+
nf = nf.join(nf["nested"].to_lists())
2215+
result = nf.head(0).nest_lists(["t", "flux", "band"], name="nested2").reset_index()
2216+
assert "objectid" in result.columns
2217+
2218+
22082219
def test_delitem_base_and_nested():
22092220
"""Test that __delitem__ works for both base and nested columns."""
22102221
base = NestedFrame(data={"a": [1, 2, 3], "b": [2, 4, 6]}, index=[0, 1, 2])

0 commit comments

Comments
 (0)