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.to_struct should have optional name #12947

Closed
2 tasks done
deanm0000 opened this issue Dec 7, 2023 · 1 comment · Fixed by #12998
Closed
2 tasks done

DataFrame.to_struct should have optional name #12947

deanm0000 opened this issue Dec 7, 2023 · 1 comment · Fixed by #12998
Labels
enhancement New feature or an improvement of an existing feature python Related to Python Polars

Comments

@deanm0000
Copy link
Collaborator

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

df=pl.DataFrame(
    [
        pl.Series("a", [1, 2, 3], dtype=pl.Int64),
        pl.Series("b", [2, 3, 4], dtype=pl.Int64)
    ]
)
### Can't do
df.to_struct()
## Can only do 
df.to_struct('')

There isn't a similar restriction on the Series initiator because we can do

pl.Series(values=[{'a':1, 'b':2}, {'a':2, 'b':4}])

Log output

No response

Issue description

Should make name optional.

Expected behavior

Should have same behavior as pl.Series constructor. It's, obviously, not a big deal but it'd be nice.

Installed versions

--------Version info---------
Polars:               0.19.18
Index type:           UInt32
Platform:             Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.31
Python:               3.10.13 (main, Nov  1 2023, 14:20:38) [GCC 10.2.1 20210110]

----Optional dependencies----
adbc_driver_manager:  <not installed>
cloudpickle:          3.0.0
connectorx:           0.3.1
deltalake:            <not installed>
fsspec:               2023.10.0
gevent:               <not installed>
matplotlib:           3.8.1
numpy:                1.26.1
openpyxl:             3.1.2
pandas:               2.1.2
pyarrow:              14.0.0
pydantic:             <not installed>
pyiceberg:            <not installed>
pyxlsb:               1.0.10
sqlalchemy:           2.0.23
xlsx2csv:             0.8.1
xlsxwriter:           3.1.9
@deanm0000 deanm0000 added bug Something isn't working python Related to Python Polars labels Dec 7, 2023
@universalmind303 universalmind303 added enhancement New feature or an improvement of an existing feature and removed bug Something isn't working labels Dec 11, 2023
@alexander-beedie
Copy link
Collaborator

alexander-beedie commented Dec 11, 2023

The default Series name if not specified is indeed the empty string - doesn't seem unreasonable to be consistent here ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or an improvement of an existing feature python Related to Python Polars
Projects
None yet
3 participants