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

Initializing a struct series with an array type field using Numpy arrays results in nulls #18840

Open
2 tasks done
jkim- opened this issue Sep 21, 2024 · 0 comments
Open
2 tasks done
Labels
bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars

Comments

@jkim-
Copy link

jkim- commented Sep 21, 2024

Checks

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of Polars.

Reproducible example

x = np.array([1,2,3], dtype=np.int32)
pl.Series(
    values=[{"x": x}], 
    dtype=pl.Struct({
        "x": pl.Array(inner=pl.Int32, shape=(3,)),
    }),
).struct.unnest()

results in

x
--
array[i32, 3]
null

Log output

No response

Issue description

I'm trying to create a series backed by Numpy arrays to avoid copying, and the resulting series only contained nulls.

Expected behavior

x = np.array([1,2,3], dtype=np.int32)
pl.Series(
    values=[{"x": list(x)}], 
    dtype=pl.Struct({
        "x": pl.Array(inner=pl.Int32, shape=(3,)),
    }),
).struct.unnest()

works fine:

x
--
array[i32, 3]
[1, 2, 3]

Installed versions

--------Version info---------
Polars:              1.7.1
Index type:          UInt32
Platform:            Linux-5.10.225-191.878.amzn2int.x86_64-x86_64-with-glibc2.31
Python:              3.11.9 | packaged by conda-forge | (main, Apr 19 2024, 18:36:13) [GCC 12.3.0]

----Optional dependencies----
adbc_driver_manager  <not installed>
altair               <not installed>
cloudpickle          2.2.1
connectorx           <not installed>
deltalake            <not installed>
fastexcel            <not installed>
fsspec               2024.5.0
gevent               24.2.1
great_tables         <not installed>
matplotlib           3.8.4
nest_asyncio         1.6.0
numpy                1.26.4
openpyxl             <not installed>
pandas               2.2.2
pyarrow              16.1.0
pydantic             2.7.1
pyiceberg            <not installed>
sqlalchemy           <not installed>
torch                2.3.0
xlsx2csv             <not installed>
xlsxwriter           <not installed>
@jkim- jkim- added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Sep 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars
Projects
None yet
Development

No branches or pull requests

1 participant