python-polars Questions

4

Solved

In python polars, I was wondering if it will be possible to use .eval() to perform an operation between an element and a column. For example, given the following dataframe: import polars as pl df ...
Hoitytoity asked 2/8, 2023 at 8:6

2

How does one read a zipped csv file into a python polars DataFrame? The only current solution is writing the entire thing into memory and then passing it into pl.read_csv.
Solano asked 26/3, 2022 at 4:3

3

Solved

I have a dataframe with a certain number of groups, containing a weight column and a list of values, which can be of arbitrary length, so for example: df = pl.DataFrame( { "Group": [&qu...
Girand asked 9/11, 2022 at 8:55

4

Given an example dataframe where we have column 'b' containing lists, and each list has the same length (so it also could be converted to arrays) df_test = pl.DataFrame({'a': [1., 2., 3.], 'b': [[2...
Boor asked 25/3 at 10:19

2

Solved

I have a dataframe like: data = { "a": [[1], [2], [3, 4], [5, 6, 7]], "b": [[], [8], [9, 10], [11, 12]], } df = pl.DataFrame(data) """ ┌───────────┬───────────┐...
Ronn asked 15/9 at 17:45

4

Solved

I want to filter all duplicated rows from a polars dataframe. What I've tried: df = pl.DataFrame([['1', '1', '1', '1'], ['7', '7', '2', '7'], ['3', '9', '3', '9']]) df shape: (4, 3) ┌──────────┬──...
Velate asked 4/5, 2022 at 11:53

4

Solved

I have the following dataframe: df = pl.DataFrame({ "Column A": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], "Column B": [2, 3, 1, 4, 1, 7, 3, 2, 12, 0] }) I want to create a new colum...
Distrust asked 30/4 at 0:18

4

Solved

I am working with 2 datasets. One describes some time windows by their start and stop times. The second one contains a big list of events with their corresponding timestamps. I want to combine this...
Avilla asked 25/8 at 20:14

3

Solved

I have a Polars dataframe with a lot of duplicate data I would like to consolidate. Input: shape: (3, 2) ┌─────┬──────┐ │ id ┆ data │ │ --- ┆ --- │ │ i64 ┆ str │ ╞═════╪══════╡ │ 1 ┆ a │ │ 1 ┆ b │ ...
Leesen asked 28/8 at 18:17

4

Solved

If you come from the future, hopefully this PR has already been merged. If you don't come from the future, hopefully this answer solves your problem. I want to solve my problem only with polars (wh...
Confetti asked 28/8 at 7:29

2

Solved

I'm trying to reorder the columns in a Polars dataframe and put 5 columns out of 100 first (the document must unfortunately be somewhat readable in excel). I can't seem to find an easy way to do th...
Thenar asked 22/8 at 16:33

2

I have made a local dash-app to allow students to efficiently find/study their (measurement) data. To allow for further development, I tried to make a transition from pandas & duckdb to polars....
Gabriellegabrielli asked 5/8 at 11:50

2

Solved

import polars as pl df = pl.DataFrame( {"name": list("abcdef"), "age": [21, 31, 32, 53, 45, 26], "country": list("AABBBC")} ) df.group_by("...
Fiann asked 14/8 at 3:1

2

Solved

import polars as pl import numpy as np df_sim = pl.DataFrame({ "daily_n": [1000, 2000, 3000, 4000], "prob": [.5, .5, .5, .6], "size": 1 }) df_sim = df_sim.with_c...
Kucik asked 13/8 at 19:29

2

Solved

I have a polars dataframe that contains a datetime column. I want to convert this column to strings in the format %Y%m. For example, all dates in January 2024 should be converted to "202401&qu...
Codeclination asked 6/8 at 21:9

2

Solved

I understand Polars Series can be exported to a Python list. However, is there any way I can convert a Polars Dataframe to a Python list? In addition, if there is a one single column in the Polars ...
Miranda asked 21/2, 2023 at 19:57

4

Solved

I am a python pandas user but recently found about polars dataframe and it seems quite promising and blazingly fast. I am not able to find a way to open an excel file in polars. Polars is happily r...
Cosetta asked 28/3, 2022 at 4:23

2

Solved

Assume I have this dataframe import polars as pl df = pl.DataFrame({ 'item': ['CASH', 'CHECK', 'DEBT', 'CHECK', 'CREDIT', 'CASH'], 'quantity': [100, -20, 0, 10, 0, 0], 'value': [99, 47, None, 9...
Record asked 1/8 at 16:56

2

Solved

Given a Polars dataframe like below, how can I call explode() on both columns while expanding the null entry to the correct length to match up with its row? shape: (3, 2) ┌───────────┬─────────────...
Effie asked 30/7 at 7:59

2

Solved

Does anyone know why polars (or maybe my pycharm setup or python debugger) limits the number of rows in the output? This drives me nuts. Here is the polars code i am running but I do suspect its no...
Embrey asked 17/4, 2023 at 13:46

3

Solved

I am new to Polars and I am not sure whether I am using .with_columns() correctly. Here's a situation I encounter frequently: There's a dataframe and in .with_columns(), I apply some operation to a...
Costplus asked 1/3, 2023 at 9:8

3

Solved

The statement I'm reading data sets using Polars.read_csv() method via a Python file handler: with gzip.open(os.path.join(getParameters()['rdir'], dataset)) as compressed_file: df = pl.read_csv...
Tullusus asked 9/3, 2023 at 22:52

1

Solved

I have a data-frame with multiple columns containing list items. I eventually want to explode the list columns into rows. This will only work if all lists have the same length (per row). df.explode...
Americana asked 17/7 at 16:11

1

Solved

I have this code that generates a toy DataFrame (production df is much complex): import polars as pl import numpy as np import pandas as pd def create_timeseries_df(num_rows): date_rng = pd.date_...

3

Solved

How to sort row with spesific order df = pl.DataFrame({"currency": ["EUR","EUR","EUR","USD","USD","USD"], "alphabet":...
Gehenna asked 7/3, 2023 at 4:2

© 2022 - 2024 — McMap. All rights reserved.