Narwhals is a library that aims to unify expression across dataframe libraries. It is meant to be lightweight and focuses on python first dataframe libraries.
This examples shows how you can write dataframe agnostic code and then load up a pandas or polars data to then use with it.
You can run the example doing:
# cd examples/narwhals/ python example.py
This will run both variants one after the other.
or running the notebook:
# cd examples/narwhals jupyter notebook # pip install jupyter if you don't have it
Or you can open up the notebook in Colab: