Pandas vs polars functions

Categories

common Pandas functions and their equivalent functions in the polars library:

  1. pd.read_csv : polars.read_csv
  2. pd.DataFrame : polars.DataFrame
  3. df.head : df.first
  4. df.tail : df.last
  5. df.describe : df.summary
  6. df.corr : df.correlation
  7. df.cov : df.covariance
  8. df.dropna : df.remove_na
  9. df.fillna : df.fill_na
  10. df.groupby : df.aggregate
  11. df.pivot_table : df.spread
  12. df.melt : df.gather
  13. df.merge : df.join

These are some of the commonly used Pandas functions and their equivalent in polars library. It is possible that some functions may not have an equivalent in polars library and some additional functions may be available in polars library.

The polars library is a high-level library for data analysis and visualization in Python, built on top of the popular PyData stack (NumPy, Pandas, Matplotlib, etc.). Some common Pandas functions that have different names in polars include:

  1. Pandas ‘head’ function is called ‘first’ in polars
  2. Pandas ‘tail’ function is called ‘last’ in polars
  3. Pandas ‘drop’ function is called ‘remove’ in polars
  4. Pandas ‘groupby’ function is called ‘group’ in polars
  5. Pandas ‘agg’ function is called ‘aggregate’ in polars
  6. Pandas ‘pivot_table’ function is called ‘spread’ in polars
  7. Pandas ‘melt’ function is called ‘gather’ in polars
  8. Pandas’ cov method is named as covariance in Polars.
  9. The Pandas’ corr method is named as correlation in Polars.
  10. Pandas’ groupby method is named as aggregate in Polars.
  11. Pandas’ resample method is named as downsample in Polars.
  12. Pandas’ rolling method is named as window in Polars.

It’s important to note that polars library is not as widely used as Pandas, so if you’re familiar with Pandas, it may be best to stick with it, unless you have a specific use case for polars.