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_init_repr() inner dtypes missing pl. qualifier #15802

Closed
2 tasks done
jr200 opened this issue Apr 20, 2024 · 1 comment · Fixed by #16235
Closed
2 tasks done

to_init_repr() inner dtypes missing pl. qualifier #15802

jr200 opened this issue Apr 20, 2024 · 1 comment · Fixed by #16235
Labels
A-formatting Area: display/repr of Polars objects bug Something isn't working P-low Priority: low python Related to Python Polars

Comments

@jr200
Copy link
Contributor

jr200 commented Apr 20, 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 os
os.environ["RUST_BACKTRACE"]="full"
os.environ["POLARS_VERBOSE"]="1"

import polars as pl

print(
    pl.DataFrame([
        pl.Series("E", [0], dtype=pl.Int8),
        pl.Series("A", [[1]], dtype=pl.Array(pl.Int16, 1)),
        pl.Series("S", [{"a": 2}], dtype=pl.Struct({"a": pl.Int32})),
        pl.Series("L", [[3]], dtype=pl.List(pl.Int64)),
    ])
    .to_init_repr()
)

Log output

pl.DataFrame(
    [
        pl.Series("E", [0], dtype=pl.Int8),
        pl.Series("A", [[1]], dtype=pl.Array(Int16, width=1)),
        pl.Series("S", [{'a': 2}], dtype=pl.Struct({'a': Int32})),
        pl.Series("L", [[3]], dtype=pl.List(Int64)),
    ]
)

Issue description

The inner dtypes are missing the pl. prefix.

Expected behavior

Expect the output to be:

pl.DataFrame(
    [
        pl.Series("E", [0], dtype=pl.Int8),
        pl.Series("A", [[1]], dtype=pl.Array(pl.Int16, width=1)),
        pl.Series("S", [{'a': 2}], dtype=pl.Struct({'a': pl.Int32})),
        pl.Series("L", [[3]], dtype=pl.List(pl.Int64)),
    ]
)

Installed versions

--------Version info---------
Polars:               0.20.21
Index type:           UInt32
Platform:             macOS-14.1.1-x86_64-i386-64bit
Python:               3.11.3 (main, Mar 12 2024, 20:00:56) [Clang 15.0.0 (clang-1500.3.9.4)]

----Optional dependencies----
adbc_driver_manager:  <not installed>
cloudpickle:          <not installed>
connectorx:           <not installed>
deltalake:            <not installed>
fastexcel:            <not installed>
fsspec:               <not installed>
gevent:               <not installed>
hvplot:               0.9.2
matplotlib:           <not installed>
nest_asyncio:         1.6.0
numpy:                1.26.4
openpyxl:             <not installed>
pandas:               2.2.1
pyarrow:              15.0.2
pydantic:             <not installed>
pyiceberg:            <not installed>
pyxlsb:               <not installed>
sqlalchemy:           <not installed>
xlsx2csv:             <not installed>
xlsxwriter:           <not installed>

@jr200 jr200 added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Apr 20, 2024
@jr200 jr200 changed the title to_init_repr inner dtypes missing pl. qualifier to_init_repr() inner dtypes missing pl. qualifier Apr 20, 2024
@stinodego stinodego added A-formatting Area: display/repr of Polars objects P-low Priority: low and removed needs triage Awaiting prioritization by a maintainer labels Apr 21, 2024
@stinodego
Copy link
Member

stinodego commented Apr 21, 2024

Thanks for the report! A smaller repro:

import polars as pl

s = pl.Series([{"a": 2}])
print(s.to_init_repr())

As a temporary workaround, you can import all datatypes directly using from polars.datatypes import *. That will make sure your init_repr will work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-formatting Area: display/repr of Polars objects bug Something isn't working P-low Priority: low python Related to Python Polars
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants