pandas.Index.astype
pandas 3.1.1 · Index objects · method
Convert to another dtype. A DataFrame accepts a mapping to choose conversions column by column.
Call syntax
Index.astype(dtype, copy=True)Run the example
Edit the example and select Run Python to see the result.
Parameters
| Parameter | Requirement | Accepted values and behavior |
|---|---|---|
dtype |
Required Positional or keyword |
numpy dtype or pandas type Choose the data type for the input conversion or result. |
copy |
Optional Positional or keyword Default True |
bool Control whether data is copied where the API supports that choice. |
Returns
Index