Return the dataframe interchange object implementing the interchange protocol.
nan_as_null is DEPRECATED and has no effect. Please avoid using it; it will be removed in a future release.
Whether to allow memory copying when exporting. If set to False it would cause non-zero-copy exports to fail.
The object which consuming library can use to ingress the dataframe.
Notes
Details on the interchange protocol: https://data-apis.org/dataframe-protocol/latest/index.html
Examples
>>> df_not_necessarily_pandas = pd.DataFrame({'A': [1, 2], 'B': [3, 4]})
>>> interchange_object = df_not_necessarily_pandas.__dataframe__()
>>> interchange_object.column_names()
Index(['A', 'B'], dtype='object')
>>> df_pandas = (pd.api.interchange.from_dataframe
... (interchange_object.select_columns_by_name(['A'])))
>>> df_pandas
A
0 1
1 2
These methods (column_names, select_columns_by_name) should work for any dataframe library which implements the interchange protocol.
© 2008–2011, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
© 2011–2025, Open source contributors
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/2.3.0/reference/api/pandas.DataFrame.__dataframe__.html