Skip to content

Tag: python-polars

Adding secondary group by clause using groupby_dynamic() operation in polar

I would like to groupby the data in interval of a hourly/daily/weekly and further group by certain other clauses. I was able to acheive groupby hourly/daily/weekly basis by using groupby_dynamic option provided by polars. How do we add a secondary non datetime groupby clause to the polars dataframe after using groupby_dynamic operation in polar? The sample dataframe read from csv

Polars: settings not to display ellipsis

Polars chops some text instead of showing all text like the following Link Name https://… name1 https://… name2 I want Polars to show all text of Link Col How can I do that? Answer You should change pl.Config() settings – pl.Config.set_fmt_str_lengths(n) (see doc) If you just want to check, how new table view looks like, you can use with pl.Config()

How to roll up duplicate observation in Python polars?

I have a data frame as- Here I would like to find out duplicates considering last_name and firs_name columns and if any duplicates found their respective ssn needs to be rolled up with semicolon(;) if SSN are not different. if SSN are also same only one SSN needs to be present. the expected output as: Here since mallesh yamulla is

Add timedelta to a date column above weeks

How would I add 1 year to a column? I’ve tried using map and apply but I failed miserably. I also wonder why accepts integers while it advertises that it only accepts str or pli.Expr. A small hack workaround is: but this won’t work for months or days. I can’t just add a number or I’ll get a: Most

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 into polars native datetimes. Answer Polars’ Datetime is represented as unix epoch in either, nanoseconds, microseconds or milliseconds. So with that knowledge we can convert the seconds to milliseconds and