An Empirical Study on the Energy Usage and Performance of Pandas and Polars Data Analysis Python Libraries
Context. Python’s growing popularity in data analysis and the contemporary emphasis on energy-efficient software tools necessitate an investigation into the energy implications of data operations, particularly in resource-intensive domains like data science. This study provides fundamental insights for library selection, focusing on Pandas, a widely-used Python data manipulation library, and Polars, a Rust-based library known for its performance.
Goal. We aim to compare and analyze the energy usage of Polars and Pandas. The study aims to provide insights for developers and data scientists by identifying scenarios where one library outperforms the other in terms of energy usage while exploring the possible correlations between energy usage and performance metrics.
Method. We performed four separate experiment blocks including 8 Data Analysis Tasks (DATs) from an official TPCH Benchmark done by Polars and 6 Synthetic DATs. Both DATs groups are run with small and large dataframes and for both libraries.
Results. Polars is more energy-efficient than Pandas when dealing with large dataframes. For small dataframes, the TPCH Benchmarking DATs does not show a statistically significant difference, while for the Synthetic DATs, Polars performs significantly better. We identified strong positive correlations between energy usage and execution time, as well as memory usage for Pandas, while Polars did not show significant memory usage correlations for the majority of runs. Additionally, there was a significantly negative correlation between energy usage and CPU usage for Pandas.
Conclusions. The study recommends using Polars for energy-efficient and fast data analysis, emphasizing the importance of CPU core utilization in library selection.