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

Float literal formatting outputs different things dependent on where it is used #18981

Closed
2 tasks done
coastalwhite opened this issue Sep 27, 2024 · 1 comment · Fixed by #18982
Closed
2 tasks done
Assignees
Labels
accepted Ready for implementation bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars

Comments

@coastalwhite
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

pl.DataFrame().with_columns(a=pl.lit(0.0)).with_columns(b=pl.col(“a”).cast(pl.String), c=pl.lit(0.0).cast(pl.String))

Outputs:

shape: (1, 3)
┌─────┬─────┬─────┐
│ a   ┆ b   ┆ c   │
│ --- ┆ --- ┆ --- │
│ f64 ┆ str ┆ str │
╞═════╪═════╪═════╡
│ 0.0 ┆ 0.0 ┆ 0   │
└─────┴─────┴─────┘

Log output

No response

Issue description

Inconsistency

Expected behavior

Consistency

Installed versions

Replace this line with the output of pl.show_versions(). Leave the backticks in place.
@coastalwhite coastalwhite added bug Something isn't working python Related to Python Polars needs triage Awaiting prioritization by a maintainer labels Sep 27, 2024
@ritchie46
Copy link
Member

ritchie46 commented Sep 27, 2024

Likely due to the new scalar. All the formatting of columns should ensure it goes into polars-core/fmt.

Ah, nevermind.

I am not entirely sure it should be the same. One is formatting behavior (which is even subjective to env vars), the other is casting behavior. They should be independent.

We don't want that the casting for floats changes because the formatting of the tables have changed.

EDIT:

I now see that the cast is different depending on it being a column source or literal source. That should be fixed indeed.

@ritchie46 ritchie46 self-assigned this Sep 27, 2024
@c-peters c-peters added the accepted Ready for implementation label Sep 29, 2024
@c-peters c-peters added this to Backlog Sep 29, 2024
@c-peters c-peters moved this to Done in Backlog 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