Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
stinodego committed Mar 27, 2024
1 parent c6636a5 commit 47d93fc
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions py-polars/tests/unit/constructors/test_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,16 @@ def test_df_init_from_series_strict() -> None:
def test_df_init_rows_overrides_non_existing() -> None:
with pytest.raises(pl.SchemaError, match="nonexistent column"):
pl.DataFrame([{"a": 1, "b": 2}], schema_overrides={"c": pl.Int8})


# https://github.com/pola-rs/polars/issues/15245
def test_df_init_nested_mixed_types() -> None:
data = [{"key": [{"value": 1}, {"value": 1.0}]}]

with pytest.raises(TypeError, match="unexpected value"):
pl.DataFrame(data, strict=True)

df = pl.DataFrame(data, strict=False)

assert df.schema == {"key": pl.List(pl.Struct({"value": pl.Float64}))}
assert df.to_dicts() == [{"key": [{"value": 1.0}, {"value": 1.0}]}]

0 comments on commit 47d93fc

Please sign in to comment.