rust-polars

polars native way to convert unix timestamp to date

polars native way to convert unix timestamp to date Question: I’m working with some data frames that contain Unix epochs in ms, and would like to display the entire timestamp series as a date. Unfortunately, the docs did not help me find a polars native way to do this, and I’m reaching out here. Solutions …

Total answers: 2

How to efficiently create an index-like Polars DataFrame from multiple sparse series?

How to efficiently create an index-like Polars DataFrame from multiple sparse series? Question: I would like to create a DataFrame that has an "index" (integer) from a number of (sparse) Series, where the index (or primary key) is NOT necessarily consecutive integers. Each Series is like a vector of (index, value) tuple or {index: value} …

Total answers: 2

How can I add a column of empty arrays to polars.DataFrame?

How can I add a column of empty arrays to polars.DataFrame? Question: I am trying to add a column of empty lists to a polars dataframe in python. My code import polars as pl a = pl.DataFrame({‘a’: [1, 2, 3]}) a.with_columns([pl.lit([]).alias(‘b’)]) throws Traceback (most recent call last): File "<input>", line 1, in <module> a.with_columns([pl.lit([]).alias(‘b’)]) File …

Total answers: 1

Repeat rows in a Polars DataFrame based on column value

Repeat rows in a Polars DataFrame based on column value Question: I would like to expand the following Polars dataframe by repeating rows based on values in the quantity column. Original DataFrame: Fruit Quantity Apple 2 Banana 3 Expected Output: Fruit Quantity Apple 1 Apple 1 Banana 1 Banana 1 Banana 1 Here is a …

Total answers: 1

Repeating a date in polars and exploding it

Repeating a date in polars and exploding it Question: I have a polars dataframe with two date columns that represent a start and end date and then a value that I want to repeat for all dates in between those two dates so that I can join those on other tables. Example input is id …

Total answers: 3