Compute the number of unique combinations while excluding those containing missing values
I’d like to count the number of unique values when combining several columns at once. My idea so far was to use pl.struct(...).n_unique()
, which works fine when I consider missing values as a unique value:
Filter and condense a polars dataframe into a few columns of lists
Given a list of column names in the variable column_names(more than 20, but in this example reduced to 3) and the dataframe below:
Polars get nth position from Expression type
When I’m aggregating data in polars (e.g. groupby
, rolling
, group_by_dynamic
and calling .agg(...)
) how can I get a specific nth position? (In Polars lingo: How can I select an element within an expression within aggregation?)
Ranking two list columns in polars based on elements in the first list, then the second
Due to certain restrictions, polars version is 0.18.4
Ranking two list columns in polars based on elements in the first list, then the second
Due to certain restrictions, polars version is 0.18.4
Using starts_with for comparing a string to a list of strings in Polars
Could I do a starts_with comparison for a string with a list of strings, return True if the string starts with any of the strings in the list, this is what I come up with,
Fill several polars columns with a constant value
I have this code
Python + Polars: how can I convert the values of a column with type `enum` into their integer (“physical”) representation?
The user guide suggests that enums have a physical, integer representation: https://docs.pola.rs/user-guide/concepts/data-types/categoricals/#enum-type
Split a polars DataFrame into multiple chunks with groupby
Consider the following pl.DataFrame
s:
Split a polars DataFrame into multiple chunks with groupby
Consider the following pl.DataFrame
s: