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

from_pandas: pyo3_runtime.PanicException: cannot set validity of a null array #6412

Closed
2 tasks done
gam-phon opened this issue Jan 24, 2023 · 1 comment · Fixed by #6430
Closed
2 tasks done

from_pandas: pyo3_runtime.PanicException: cannot set validity of a null array #6412

gam-phon opened this issue Jan 24, 2023 · 1 comment · Fixed by #6430
Labels
bug Something isn't working python Related to Python Polars

Comments

@gam-phon
Copy link
Contributor

gam-phon commented Jan 24, 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

I am trying to transfer between pandas and polars and found this issue when loading data from pandas to polars, if I load them directly it will be no issue but from_pandas cause the issue.

The element sometime is dict and another is None. that is when the issue exists.

Reproducible example

import pandas as pd
import polars as pl

data = [
    {
        "a": {
            "b": None,
        },
    },
    {"a": None},
]

# No issue
df_pandas = pd.DataFrame(data)
print(df_pandas)
# No issue
df_polars = pl.DataFrame(data)
print(df_polars)

# Here is the issue
pl.from_pandas(df_pandas)


data = [
    {
        "a": {
            "b": None,
        },
    },
    {"a": {}},
]
# No issue
pl.from_pandas(pd.DataFrame(data))

data = [
    {
        "a": {
            "b": 1,
        },
    },
    {"a": None},
]

# No issue
pl.from_pandas(pd.DataFrame(data))

data = [
    {
        "a": {
            "b": None,
        },
    },
]

# No issue
pl.from_pandas(pd.DataFrame(data))

Expected behavior

I know that the data maybe is corrupted but loading them to polars directly has no issue so I am expecting same behavior in both (pl.from_pandas and pl.DataFram) either raise error in both or ignore and handle in both

Installed versions

---Version info---
Polars: 0.15.16
Index type: UInt32
Platform: macOS-13.1-arm64-arm-64bit
Python: 3.11.1 (main, Dec 23 2022, 09:28:24) [Clang 14.0.0 (clang-1400.0.29.202)]
---Optional dependencies---
pyarrow: 10.0.1
pandas: 1.5.3
numpy: 1.24.1
fsspec: <not installed>
connectorx: 0.3.2_alpha.1
xlsx2csv: <not installed>
deltalake: <not installed>
matplotlib: <not installed>
None
@gam-phon gam-phon added bug Something isn't working python Related to Python Polars labels Jan 24, 2023
@gam-phon
Copy link
Contributor Author

Maybe this is related to

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

Successfully merging a pull request may close this issue.

1 participant