From 743de7b6bf3f4f0ccb4e8154b6b08b4af865201d Mon Sep 17 00:00:00 2001 From: Doug Branton Date: Fri, 9 Aug 2024 12:09:17 -0700 Subject: [PATCH] add accessor test for query_flat index dtype --- tests/nested_pandas/series/test_accessor.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/nested_pandas/series/test_accessor.py b/tests/nested_pandas/series/test_accessor.py index a4ac4db..b63c879 100644 --- a/tests/nested_pandas/series/test_accessor.py +++ b/tests/nested_pandas/series/test_accessor.py @@ -1,3 +1,4 @@ +import nested_pandas as npd import numpy as np import pandas as pd import pyarrow as pa @@ -487,6 +488,17 @@ def test_query_flat_empty_rows(): assert_series_equal(filtered, desired) +def test_query_flat_with_empty_result(): + """Make sure the index is properly set for empty result cases""" + base = npd.NestedFrame({"a": []}, index=pd.Index([], dtype=np.float64)) + nested = npd.NestedFrame({"b": []}, index=pd.Index([], dtype=np.float64)) + + ndf = base.add_nested(nested, "nested") + + res = ndf.nested.nest.query_flat("b > 2") + assert res.index.dtype == np.float64 + + @pytest.mark.parametrize( "df", [