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

to_dicts with binary column yields list[int] instead of bytes. #18953

Closed
2 tasks done
WolfEYc opened this issue Sep 26, 2024 · 1 comment · Fixed by #18960
Closed
2 tasks done

to_dicts with binary column yields list[int] instead of bytes. #18953

WolfEYc opened this issue Sep 26, 2024 · 1 comment · Fixed by #18960
Assignees
Labels
accepted Ready for implementation bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars

Comments

@WolfEYc
Copy link

WolfEYc commented Sep 26, 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

import polars as pl
import secrets
df = pl.DataFrame({"tokens": [ secrets.token_bytes(16)]})
print(df)
print(df.to_dicts())

Log output

shape: (1, 1)
┌─────────────────────────────────┐
│ tokens                          │
│ ---                             │
│ binary                          │
╞═════════════════════════════════╡
│ b"G\x08\x99\xb6\xc1+\xb8\xf3~\… │
└─────────────────────────────────┘
[{'tokens': [71,
   8,
   153,
   182,
   193,
   43,
   184,
   243,
   126,
   246,
   129,
   29,
   192,
   176,
   97,
   80]}]

Issue description

if i have two elements instead...

df = pl.DataFrame({"tokens": [ secrets.token_bytes(16), secrets.token_bytes(16)]})
print(df.to_dicts)

outputs:
[{'tokens': b'\xcd\x1b\x96\xdct\x90<\xe2\x13\xb5l\x8b\x89\xf8F+'},
{'tokens': b'\xa9\x16n\x90F\xfc\xfd\x13\x96%\xad$n\x93\xa4\xc6'}]

Expected behavior

I previously elaborated

Installed versions

--------Version info---------
Polars:              1.8.2
Index type:          UInt32
Platform:            macOS-14.6.1-arm64-arm-64bit
Python:              3.12.6 (main, Sep  6 2024, 19:03:47) [Clang 15.0.0 (clang-1500.3.9.4)]

----Optional dependencies----
adbc_driver_manager  <not installed>
altair               <not installed>
cloudpickle          <not installed>
connectorx           <not installed>
deltalake            <not installed>
fastexcel            <not installed>
fsspec               <not installed>
gevent               <not installed>
great_tables         <not installed>
matplotlib           <not installed>
nest_asyncio         <not installed>
numpy                <not installed>
openpyxl             <not installed>
pandas               <not installed>
pyarrow              <not installed>
pydantic             2.9.2
pyiceberg            <not installed>
sqlalchemy           <not installed>
torch                <not installed>
xlsx2csv             <not installed>
xlsxwriter           <not installed>```

</details>
@WolfEYc WolfEYc added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Sep 26, 2024
@coastalwhite
Copy link
Collaborator

I am pretty sure this is a ScalarColumn issue.

@coastalwhite coastalwhite self-assigned this Sep 26, 2024
coastalwhite added a commit to coastalwhite/polars that referenced this issue Sep 27, 2024
@c-peters c-peters added the accepted Ready for implementation label Sep 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Ready for implementation bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants