We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I find myself regularly un-nesting structures such as
{ equipment: { name=XXX, level=YYY, zone=ZZZ, ...} sensor: {name=ABC, level=123, ... } }
i.e. the names of the exploded columns for equipment and sensor clash. This requires code like
.unnest("equipment").rename({"name":"equipment_name", "level":"equipment_level" ... }) .unnest("sensor").rename({"name":"sensor_name", "level":"sensor_level" ... })
It would be nice if rename had arguments to generate the names. The simplest option would be a prefix, i.e.
rename
.unnest("equipment", prefix="equipment_").unnest("sensor", prefix="sensor_")
Another option would be to infer the prefix from the base column name, i.e.
.unnest("equipment", add_prefix=True).unnest("sensor", add_prefix=True)
'
would add the prefix based on the first argument etc.
The text was updated successfully, but these errors were encountered:
Some struct methods were recently added to .name which could help.
.name
df.with_columns( pl.col("equipment").name.prefix_fields("equipment_"), pl.col("sensor").name.prefix_fields("sensor_") ).unnest("equipment", "sensor")
Also related: #12353
Sorry, something went wrong.
Thanks @cmdlineluser that works for me
No branches or pull requests
Description
I find myself regularly un-nesting structures such as
i.e. the names of the exploded columns for equipment and sensor clash. This requires code like
It would be nice if
rename
had arguments to generate the names. The simplest option would be a prefix, i.e.Another option would be to infer the prefix from the base column name, i.e.
'
would add the prefix based on the first argument etc.
The text was updated successfully, but these errors were encountered: