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

fix(rust,python): updated Display trait for enum categoricals #13331

Merged
merged 2 commits into from
Dec 31, 2023

Conversation

alexander-beedie
Copy link
Collaborator

@alexander-beedie alexander-beedie commented Dec 30, 2023

Closes #13330.

Updated DataType::Display trait for enum categoricals.

Example

import polars as pl
compass_points = ["North", "East", "South", "West"]

df = pl.DataFrame(
    data = {"directions": compass_points},
    schema_overrides = {"directions": pl.Enum(compass_points)},
)
print( df )
# shape: (4, 1)
# ┌────────────┐
# │ directions │
# │ ---        │
# │ enum       │  << previously showed 'cat'
# ╞════════════╡
# │ North      │
# │ East       │
# │ South      │
# │ West       │
# └────────────┘

@github-actions github-actions bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars labels Dec 30, 2023
@alexander-beedie alexander-beedie changed the title fix(rust,python): update dtype Display trait for enum categorical fix(rust,python): updated dtype Display trait for enum categoricals Dec 30, 2023
@alexander-beedie alexander-beedie changed the title fix(rust,python): updated dtype Display trait for enum categoricals fix(rust,python): updated Display trait for enum categoricals Dec 30, 2023
Copy link
Member

@stinodego stinodego left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call - just one comment on the implementation!

crates/polars-core/src/datatypes/dtype.rs Outdated Show resolved Hide resolved
@stinodego stinodego added the A-dtype-categorical Area: categorical data type label Dec 31, 2023
Co-authored-by: Stijn de Gooijer <stijn@degooijer.io>
@alexander-beedie alexander-beedie merged commit b36a229 into pola-rs:main Dec 31, 2023
25 checks passed
@alexander-beedie alexander-beedie deleted the datatype-display-enum branch December 31, 2023 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-dtype-categorical Area: categorical data type fix Bug fix python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enum display possibly incorrect?
2 participants