diff --git a/polars-v-pandas/dataframe_conversions.py b/polars-v-pandas/dataframe_conversions.py new file mode 100644 index 0000000000..f210641da6 --- /dev/null +++ b/polars-v-pandas/dataframe_conversions.py @@ -0,0 +1,29 @@ +import narwhals as nw +import polars as pl +from data_generation import generate_data + +polars_df = pl.DataFrame(generate_data(4)) +polars_df + +pandas_df = polars_df.to_pandas() +type(pandas_df) +pandas_df + +polars_df = pl.from_pandas(pandas_df) +type(polars_df) +polars_df + + +def agnositic_groupby(df): + return ( + nw.from_native(df) + .group_by("region") + .agg(nw.col("sales_income").sum()) + .sort("region") + .to_native() + ) + + +agnositic_groupby(pandas_df) + +agnositic_groupby(polars_df)