class_docstr: Unit tests for arithmetic operations of numeric data types.
  
  A few test cases are disabled because pandas-on-Spark returns float64 whereas pandas
  returns float32.
  The underlying reason is the respective Spark operations return DoubleType always.
class_docstr_tok: ["Unit","tests","for","arithmetic","operations","of","numeric","data","types",".","A","few","test","cases","are","disabled","because","pandas-on-Spark","returns","float64","whereas","pandas","returns","float32",".","The","underlying","reason","is","the","respective","Spark","operations","return","DoubleType","always","."]
code: def test_astype(self):
      pdf, psdf = self.pdf, self.psdf
      for col in self.numeric_df_cols:
          pser, psser = pdf[col], psdf[col]
  
          for int_type in [int, np.int32, np.int16, np.int8]:
              if not pser.hasnans:
                  self.assert_eq(
                      pser.astype(int_type), psser.astype(int_type)
                  )
              else:
                  self.assertRaisesRegex(
                      ValueError,
                      "Cannot convert %s with missing "
                      "values to integer" % psser._dtype_op.pretty_name,
                      lambda: psser.astype(int_type),
                  )
  
          self.assert_eq(pser.astype(bool), psser.astype(bool))
          self.assert_eq(pser.astype(float), psser.astype(float))
          self.assert_eq(
              pser.astype(np.float32), psser.astype(np.float32)
          )
          self.assert_eq(pser.astype(str), psser.astype(str))
          self.assert_eq(
              pser.astype("category"), psser.astype("category")
          )
          cat_type = CategoricalDtype(categories=[2, 1, 3])
          self.assert_eq(pser.astype(cat_type), psser.astype(cat_type))
      if (
          extension_object_dtypes_available
          and extension_float_dtypes_available
      ):
          pser = pd.Series(
              pd.Categorical([1.0, 2.0, 3.0]), dtype=pd.Float64Dtype()
          )
          psser = ps.from_pandas(pser)
          self.assert_eq(
              pser.astype(pd.BooleanDtype()),
              psser.astype(pd.BooleanDtype()),
          )
  
file_path: spark/python/pyspark/pandas/tests/data_type_ops/test_as_type.py
imports: import unittest
  import pandas
  import numpy
  from pandas.api.types import CategoricalDtype
  from pyspark import pandas
  from pyspark.testing.pandasutils import PandasOnSparkTestCase
  from pyspark.pandas.tests.data_type_ops.testing_utils import OpsTestBase
  from pyspark.pandas.typedef.typehints import extension_dtypes_available, extension_float_dtypes_available, extension_object_dtypes_available
label_desc: Use image node_id 1 for calling the AsTypeTestsMixin obj's underlying member method code with example usage: obj.test_astype() without return types