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: Add strict parameter to rename_fields #19646

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mahmudsudo
Copy link

closes #19132

>>> s = s.struct.rename_fields(["c", "d"])
>>> s.struct.fields
['c', 'd']
>>> s.struct.rename_fields(["c", "d"], strict=True)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I reckon the example would be more informative if you:

  • show the error you get if you try to rename but provide the wrong number of names with strict=True;
  • show what happens if you try to rename but provide the wrong number of names with strict=False;
  • both of the above

@@ -332,7 +336,7 @@ def with_fields(
│ 1.0 ┆ 4 ┆ 40 ┆ 10 │
│ 2.0 ┆ 9 ┆ 18 ┆ 2 │
│ 3.0 ┆ 16 ┆ 48 ┆ 3 │
└─────┴─────┴──────┴─────────┘
└─────┴─────┴──���────┴───���──────┘
Copy link
Collaborator

Choose a reason for hiding this comment

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

Funky formatting happening here 😬

@@ -214,7 +216,7 @@ def rename_fields(self, names: Sequence[str]) -> Expr:
│ struct_col │
│ --- │
│ struct[4] │
╞═════════════════════╡
╞══════��═══════════════╡
Copy link
Collaborator

Choose a reason for hiding this comment

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

Funky formatting happening here 😬

@rodrigogiraoserrao rodrigogiraoserrao changed the title fix : strict parameter is enabled by default fix: Add strict parameter to rename_fields Nov 5, 2024
@github-actions github-actions bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars and removed title needs formatting labels Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

struct.rename_fields should have a strict parameter that is enabled by default.
2 participants