Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdlineluser committed Jul 26, 2023
1 parent fce126a commit 8056f7e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions py-polars/tests/unit/datatypes/test_struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,3 +857,9 @@ def test_struct_null_count_strict_cast() -> None:
s = pl.Series([{"a": None}]).cast(pl.Struct({"a": pl.Categorical}))
assert s.dtype == pl.Struct([pl.Field("a", pl.Categorical)])
assert s.to_list() == [{"a": None}]


def test_struct_get_field_by_index() -> None:
df = pl.DataFrame({"val": [{"a": 1, "b": 2}]})
expected = {"b": [2]}
assert df.select(pl.all().struct[1]).to_dict(as_series=False) == expected

0 comments on commit 8056f7e

Please sign in to comment.