Closed
Description
If someone wants a standardised way of selecting columns 'a' and 'b' using the interchange protocol, then it would be nice to be able to do something like
df.__dataframe__().select_columns_by_name(['a', 'b']).to_native()
pandas and Polars both use ._df
for this:
In [24]: pl.DataFrame({'a': [1,2,3], 'b': [4,5,6], 'c': [7,8,9]}).__dataframe__().select_columns_by_name(['a', 'b'])._df
...:
Out[24]:
shape: (3, 2)
┌─────┬─────┐
│ a ┆ b │
│ --- ┆ --- │
│ i64 ┆ i64 │
╞═════╪═════╡
│ 1 ┆ 4 │
│ 2 ┆ 5 │
│ 3 ┆ 6 │
└─────┴─────┘
In [25]: pd.DataFrame({'a': [1,2,3], 'b': [4,5,6], 'c': [7,8,9]}).__dataframe__().select_columns_by_name(['a', 'b'])._df
...:
Out[25]:
a b
0 1 4
1 2 5
2 3 6
but that's not standardised by the interchange protocol
Use-case: the interchange level of support which we have in Narwhals: narwhals-dev/narwhals#1263
Metadata
Metadata
Assignees
Labels
No labels