to_pandas#
- causalpy.input_data.to_pandas(data, *, argument_name='data')[source]#
Convert a dataframe-like input to a pandas
DataFrame.Pandas inputs are copied so that later index renaming does not mutate the caller’s dataframe. Inputs from other dataframe libraries are converted through Narwhals and end up with a default
RangeIndex.- Parameters:
data (
NativeDataFrame) – Any eager dataframe supported by Narwhals, such as a pandas, Polars, or PyArrow table.argument_name (
str) – Name of the calling argument, used in the error message.
- Returns:
A pandas dataframe that the caller owns and may modify in place.
- Return type:
- Raises:
TypeError – If the input is not a dataframe that Narwhals can convert eagerly.
Examples
>>> import pandas as pd >>> from causalpy.input_data import to_pandas >>> to_pandas(pd.DataFrame({"y": [1, 2]})) y 0 1 1 2