Skip to content

Commit

Permalink
docs(python): add note about include_index in from_pandas regardi…
Browse files Browse the repository at this point in the history
…ng "default indices" (pola-rs#14920)
  • Loading branch information
MarcoGorelli authored Mar 8, 2024
1 parent de5bad0 commit cf747f9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions py-polars/polars/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ def from_pandas(
include_index: bool = False,
) -> DataFrame | Series:
"""
Construct a Polars DataFrame or Series from a pandas DataFrame or Series.
Construct a Polars DataFrame or Series from a pandas DataFrame, Series, or Index.
This operation clones data.
Expand All @@ -675,6 +675,12 @@ def from_pandas(
include_index : bool, default False
Load any non-default pandas indexes as columns.
.. note::
If the input is a pandas ``Series`` or ``DataFrame`` and has a nameless
index which just enumerates the rows, then it will not be included in the
result, regardless of this parameter. If you want to be sure to include it,
please call ``.reset_index()`` prior to calling this function.
Returns
-------
DataFrame
Expand All @@ -697,7 +703,7 @@ def from_pandas(
│ 4 ┆ 5 ┆ 6 │
└─────┴─────┴─────┘
Constructing a Series from a :class:`pd.Series`:
Constructing a Series from a :class:`pandas.Series`:
>>> import pandas as pd
>>> pd_series = pd.Series([1, 2, 3], name="pd")
Expand Down

0 comments on commit cf747f9

Please sign in to comment.