Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataFrame from dicts fails with InvalidArgumentError("It is not possible to concatenate arrays of different data types.") #6910

Closed
2 tasks done
s-b90 opened this issue Feb 15, 2023 · 1 comment
Labels
bug Something isn't working python Related to Python Polars

Comments

@s-b90
Copy link

s-b90 commented Feb 15, 2023

Polars version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of Polars.

Issue description

When trying to create DF from dicts it may raise an error, even when schema provided.
Note that creating from dict works fine with same example.

pl.DataFrame({'node_groups': [
    [{'nodes': [{'name': 'a', 'time': 0}]}],
    [{'nodes': []}],
]},
    schema={'node_groups': 
         pl.List(
             pl.Struct([
                 pl.Field('nodes', pl.List(
                     pl.Struct([
                         pl.Field('name', pl.Utf8), 
                         pl.Field('time', pl.UInt32)])
                 ))
             ])
         )
        }
    )
node_groups
list[struct[1]]}
[{[{"a",0}]}]
[{[]}]

Reproducible example

import polars as pl
pl.DataFrame([
    {'node_groups': [{'nodes': [{'name': 'a', 'time': 0}]}]},
    {'node_groups': [{'nodes': []}]},
],
    schema={'node_groups': 
         pl.List(
             pl.Struct([
                 pl.Field('nodes', pl.List(
                     pl.Struct([
                         pl.Field('name', pl.Utf8), 
                         pl.Field('time', pl.UInt32)])
                 ))
             ])
         )
        }
    )
PanicException: called `Result::unwrap()` on an `Err` value: InvalidArgumentError("It is not possible to concatenate arrays of different data types.")

Expected behavior

created DataFrame

Installed versions

---Version info---
Polars: 0.16.5
Index type: UInt32
Platform: Linux-5.15.0-60-generic-x86_64-with-glibc2.35
Python: 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0]
---Optional dependencies---
pyarrow: 11.0.0
pandas: 1.5.3
numpy: 1.24.2
fsspec: <not installed>
connectorx: <not installed>
xlsx2csv: <not installed>
deltalake: <not installed>
matplotlib: 3.6.3
@s-b90 s-b90 added bug Something isn't working python Related to Python Polars labels Feb 15, 2023
@ritchie46
Copy link
Member

fixed by #6897

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working python Related to Python Polars
Projects
None yet
Development

No branches or pull requests

2 participants