Skip to content

Commit d5afccd

Browse files
committed
add doc section with interchange methods
1 parent 8b35999 commit d5afccd

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

docs/extending.md

+12
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def func(df: FrameT) -> FrameT:
3737
b_std=nw.col("b").std(),
3838
)
3939
```
40+
4041
will work for any of pandas, Polars, cuDF, Modin, and PyArrow.
4142

4243
However, sometimes you don't need to do complex operations on dataframes - all you need
@@ -57,9 +58,20 @@ def func(df: Any) -> Schema:
5758
df = nw.from_native(df, eager_or_interchange_only=True)
5859
return df.schema
5960
```
61+
6062
is also supported, meaning that, in addition to the libraries mentioned above, you can
6163
also pass Ibis, DuckDB, Vaex, and any library which implements the protocol.
6264

65+
#### Interchange-only support
66+
67+
While libraries for which we have full support can benefit from the whole Narwhals API,
68+
libraries which only benefit from interchange support can only access the following methods:
69+
70+
- `.schema`, hence column names via `.schema.names()` and column types via `.schema.dtypes()`
71+
- `.to_pandas()` and `.to_arrow()`, for converting to Pandas and Arrow, respectively.
72+
- `.select(names)` (Ibis and DuckDB), where `names` is a list of (string) column names. This is useful for
73+
selecting columns before converting to another library.
74+
6375
### Extending Narwhals
6476

6577
If you want your own library to be recognised too, you're welcome open a PR (with tests)!.

docs/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Extremely lightweight and extensible compatibility layer between dataframe libra
66

77
- **Full API support**: cuDF, Modin, pandas, Polars, PyArrow
88
- **Lazy-only support**: Dask
9-
- **Interchange-level support**: Ibis, Vaex, anything else which implements the DataFrame Interchange Protocol
9+
- **Interchange-level support**: Ibis, DuckDB, Vaex, anything else which implements the DataFrame Interchange Protocol
1010

1111
Seamlessly support all, without depending on any!
1212

0 commit comments

Comments
 (0)