def _as_other_type(index_ops: IndexOpsLike, dtype: Union[(str, type, Dtype)], spark_type: DataType) -> IndexOpsLike:
    'Cast `index_ops` to a `dtype` (`spark_type`) that needs no pre-processing.\n\n    Destination types that need pre-processing: CategoricalDtype, BooleanType, and StringType.\n    '
    from pyspark.pandas.internal import InternalField
    need_pre_process = (isinstance(dtype, CategoricalDtype) or isinstance(spark_type, BooleanType) or isinstance(spark_type, StringType))
    assert (not need_pre_process), 'Pre-processing is needed before the type casting.'
    scol = index_ops.spark.column.cast(spark_type)
    return index_ops._with_new_scol(scol, field=InternalField(dtype=dtype))
Cast `index_ops` to a `dtype` (`spark_type`) that needs no pre-processing.

Destination types that need pre-processing: CategoricalDtype, BooleanType, and StringType.
def _as_other_type(index_ops: IndexOpsLike, dtype: Union[(str, type, Dtype)], spark_type: DataType) -> IndexOpsLike:
    'Cast `index_ops` to a `dtype` (`spark_type`) that needs no pre-processing.\n\n    Destination types that need pre-processing: CategoricalDtype, BooleanType, and StringType.\n    '
    from pyspark.pandas.internal import InternalField
    need_pre_process = (isinstance(dtype, CategoricalDtype) or isinstance(spark_type, BooleanType) or isinstance(spark_type, StringType))
    assert (not need_pre_process), 'Pre-processing is needed before the type casting.'
    scol = index_ops.spark.column.cast(spark_type)
    return index_ops._with_new_scol(scol, field=InternalField(dtype=dtype))