modin.pandas.Series.astype¶
- Series.astype(dtype, copy=None, errors='raise') Self[source]¶
Cast a pandas object to a specified dtype
dtype.- Parameters:
dtype (str, data type, Series or Mapping of column name -> data type) – Use a str, numpy.dtype, pandas.ExtensionDtype or Python type to cast entire pandas object to the same type. Alternatively, use a mapping, e.g. {col: dtype, …}, where col is a column label and dtype is a numpy.dtype or Python type to cast one or more of the DataFrame’s columns to column-specific types.
copy (bool, default True) – Return a copy (i.e., a new object) when
copy=True; otherwise, astype operates inplace (be very careful settingcopy=Falseas changes to values then may propagate to other pandas objects).errors ({'raise', 'ignore'}, default 'raise') –
Control raising of exceptions on invalid data for provided dtype.
raise: allow exceptions to be raisedignore: suppress exceptions. On error return original object.
- Return type:
same type as caller (Snowpark pandas
DataFrameor Snowpark pandasSeries)
Examples
Create a DataFrame:
Cast all columns to int32 (dtypes will be int64 since Snowpark pandas API will cast all integers to int64):
Cast col1 to float64 using a dictionary:
Create a series: