bigframes.pandas.MultiIndex.astype#

MultiIndex.astype(dtype,*,errors:Literal['raise','null']='raise')Index#

Create an Index with values cast to dtypes.

The class of a new Index is determined by dtype. When conversion isimpossible, a TypeError exception is raised.

Examples:

>>>idx=bpd.Index([1,2,3])>>>idxIndex([1, 2, 3], dtype='Int64')
Parameters:
  • dtype (str,data type, orpandas.ExtensionDtype) – A dtype supported by BigQuery DataFrame include'boolean','Float64','Int64','int64\[pyarrow\]','string','string\[pyarrow\]','timestamp\[us,tz=UTC\]\[pyarrow\]','timestamp\[us\]\[pyarrow\]','date32\[day\]\[pyarrow\]','time64\[us\]\[pyarrow\]'.A pandas.ExtensionDtype includepandas.BooleanDtype(),pandas.Float64Dtype(),pandas.Int64Dtype(),pandas.StringDtype(storage="pyarrow"),pd.ArrowDtype(pa.date32()),pd.ArrowDtype(pa.time64("us")),pd.ArrowDtype(pa.timestamp("us")),pd.ArrowDtype(pa.timestamp("us",tz="UTC")).

  • errors ({'raise','null'},default 'raise') – Control raising of exceptions on invalid data for provided dtype.If ‘raise’, allow exceptions to be raised if any value fails castIf ‘null’, will assign null value if value fails cast

Returns:

Index with values cast to specified dtype.

Return type:

bigframes.pandas.Index

Raises:
  • ValueError – Iferrors is not one ofraise.

  • TypeError – MultiIndex with more than 1 level does not supportastype.

On this page

This Page