@@ -367,17 +367,19 @@ def mean(self) -> Self:
367367 Examples:
368368 >>> import polars as pl
369369 >>> import pandas as pd
370+ >>> import pyarrow as pa
370371 >>> import narwhals as nw
371372 >>> df_pd = pd.DataFrame({"a": [-1, 0, 1], "b": [2, 4, 6]})
372373 >>> df_pl = pl.DataFrame({"a": [-1, 0, 1], "b": [2, 4, 6]})
374+ >>> df_pa = pa.table({"a": [-1, 0, 1], "b": [2, 4, 6]})
373375
374376 Let's define a dataframe-agnostic function:
375377
376378 >>> @nw.narwhalify
377379 ... def func(df):
378380 ... return df.select(nw.col("a", "b").mean())
379381
380- We can then pass either pandas or Polars to `func`:
382+ We can pass any supported library such as Pandas, Polars, or PyArrow to `func`:
381383
382384 >>> func(df_pd)
383385 a b
@@ -391,6 +393,13 @@ def mean(self) -> Self:
391393 ╞═════╪═════╡
392394 │ 0.0 ┆ 4.0 │
393395 └─────┴─────┘
396+ >>> func(df_pa)
397+ pyarrow.Table
398+ a: double
399+ b: double
400+ ----
401+ a: [[0]]
402+ b: [[4]]
394403 """
395404 return self .__class__ (lambda plx : self ._call (plx ).mean ())
396405
@@ -4054,17 +4063,19 @@ def mean(*columns: str) -> Expr:
40544063 Examples:
40554064 >>> import pandas as pd
40564065 >>> import polars as pl
4066+ >>> import pyarrow as pa
40574067 >>> import narwhals as nw
40584068 >>> df_pl = pl.DataFrame({"a": [1, 8, 3]})
40594069 >>> df_pd = pd.DataFrame({"a": [1, 8, 3]})
4070+ >>> df_pa = pa.table({"a": [1, 8, 3]})
40604071
40614072 We define a dataframe agnostic function:
40624073
40634074 >>> @nw.narwhalify
40644075 ... def func(df):
40654076 ... return df.select(nw.mean("a"))
40664077
4067- We can then pass either pandas or Polars to `func`:
4078+ We can pass any supported library such as Pandas, Polars, or PyArrow to `func`:
40684079
40694080 >>> func(df_pd)
40704081 a
@@ -4078,6 +4089,11 @@ def mean(*columns: str) -> Expr:
40784089 ╞═════╡
40794090 │ 4.0 │
40804091 └─────┘
4092+ >>> func(df_pa)
4093+ pyarrow.Table
4094+ a: double
4095+ ----
4096+ a: [[4]]
40814097 """
40824098
40834099 return Expr (lambda plx : plx .mean (* columns ))
0 commit comments