Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Very slow aggregate on Pandas 2.0 dataframe with pyarrow as dtype_backend

Let’s say I have the following dataframe:

Code Price
AA1 10
AA1 20
BB2 30

And I want to perform the following operation on it:

df.groupby("code").aggregate({
    "price": "sum"
})

I have tried playing with the new pyarrow dtypes introduced in Pandas 2.0 and I created 3 copies, and for each copy I measured execution time (average of 5 executions) of the operation above.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Code column dtype Price column dtype Execution time
Object float64 2.94 s
string[pyarrow] double[pyarrow] 49.5 s
string[pyarrow] float64 1.11 s

Can anyone explain why applying an aggregate function on a column with double pyarrow dtype is so slow compared to the standard numpy float64 dtype?

>Solution :

https://github.com/pandas-dev/pandas/issues/52070

Looks like groupby for arrow isn’t implemented yet – so there’s likely a arrow -> numpy happening internally leading to a loss of performance.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading