pandas.Index.to_frame
pandas 3.1.1 · Index objects · method
Turn a one-dimensional pandas object into a DataFrame.
Call syntax
Index.to_frame(index=True, name=…)Run the example
Edit the example and select Run Python to see the result.
Parameters
| Parameter | Requirement | Accepted values and behavior |
|---|---|---|
index |
Optional Positional or keyword Default True |
bool Supply row labels or control how existing row labels are used. |
name |
Optional Positional or keyword |
Hashable Set a name or identify the named object used by the operation. |
Returns
DataFrame