Category "python-polars"

Python Polars Parse Date from Epoch

How does one convert a column of i64 epoch strings into dates in polars? I've got a column of i64 representing seconds since epoch and I'd like to parse them in

Broadcast in agg when needed

In Polars, the select and with_column methods broadcast any scalars that they get, including literals: import polars as pl df.with_column(pl.lit(1).alias("y"))

Python Polars: Read Column as Datetime

How does one read a csv into a polar DataFrame and parse one of the columns as a datetime? Alternatively, how does one convert a column to a pl.datetime?

Sort within groups on entire table

If I have a single column, I can sort that column within groups using the over method. For example, import polars as pl df = pl.DataFrame({'group': [2,2,1,1,2,

How to add stuff by index

Seems like Polars is not a fan of Pandas indexes. There are some things that you can do with indexes that I don't know how to do in Polars. For example say I ha

How to add stuff by index

Seems like Polars is not a fan of Pandas indexes. There are some things that you can do with indexes that I don't know how to do in Polars. For example say I ha

How to get the groupby keys with a loop?

I need to do some somewhat complicated processing for each group after grouping. in pandas, it can be writed as follows: for i,g in df.groupby(['id','sid']):

Polars: Setting categorical column to a specific value while keeping categorical type

Can somebody help me with the preferred way to set a categorical value for some rows of a polars data frame (based on a condition)? Right now I came up with a s