code: def test_map(self):
      pidxs = [
          pd.CategoricalIndex([1, 2, 3]),
          pd.CategoricalIndex([1, 2, 3], ordered=True),
      ]
      psidxs = [ps.from_pandas(pidx) for pidx in pidxs]
  
      for pidx, psidx in zip(pidxs, psidxs):
          # Apply dict
          self.assert_eq(
              pidx.map({1: "one", 2: "two", 3: "three"}),
              psidx.map({1: "one", 2: "two", 3: "three"}),
          )
          self.assert_eq(
              pidx.map({1: "one", 2: "two", 3: "one"}),
              psidx.map({1: "one", 2: "two", 3: "one"}),
          )
          self.assert_eq(
              pidx.map({1: "one", 2: "two"}),
              psidx.map({1: "one", 2: "two"}),
          )
          self.assert_eq(
              pidx.map({1: "one", 2: "two"}),
              psidx.map({1: "one", 2: "two"}),
          )
          self.assert_eq(
              pidx.map({1: 10, 2: 20}),
              psidx.map({1: 10, 2: 20}),
          )
  
          # Apply lambda
          self.assert_eq(
              pidx.map(lambda id: id + 1),
              psidx.map(lambda id: id + 1),
          )
          self.assert_eq(
              pidx.map(lambda id: id + 1.1),
              psidx.map(lambda id: id + 1.1),
          )
          self.assert_eq(
              pidx.map(lambda id: "{id} + 1".format(id=id)),
              psidx.map(lambda id: "{id} + 1".format(id=id)),
          )
  
          # Apply series
          pser = pd.Series(["one", "two", "three"], index=[1, 2, 3])
          self.assert_eq(
              pidx.map(pser),
              psidx.map(pser),
          )
          pser = pd.Series(["one", "two", "three"])
          self.assert_eq(
              pidx.map(pser),
              psidx.map(pser),
          )
          self.assert_eq(
              pidx.map(pser),
              psidx.map(pser),
          )
          pser = pd.Series([1, 2, 3])
          self.assert_eq(
              pidx.map(pser),
              psidx.map(pser),
          )
  
          self.assertRaises(
              TypeError,
              lambda: psidx.map({1: 1, 2: 2.0, 3: "three"}),
          )
  
imports: import unittest
  import pandas
  from pandas.api.types import CategoricalDtype
  import pyspark.pandas
  from pyspark.loose_version import LooseVersion
  from pyspark.testing.pandasutils import PandasOnSparkTestCase, TestUtils
label_desc: Use image node_id 16 for calling the CategoricalIndexTestsMixin obj's underlying member method code with example usage: obj.test_map() without return types