code: def test_converter_from_pandas_map(self):
      # _key_conv is None and _value_conv is None
      conv = _create_converter_from_pandas(
          MapType(StringType(), IntegerType())
      )
      pser = pd.Series(
          [
              {"x": 1, "y": 2, "z": None, None: 3},
              {"x": 4, "y": None, None: 5},
              None,
          ]
      )
      assert_series_equal(
          conv(pser),
          pd.Series(
              [
                  [("x", 1), ("y", 2), ("z", None), (None, 3)],
                  [("x", 4), ("y", None), (None, 5)],
                  None,
              ]
          ),
      )
  
      # _key_conv is None and _value_conv is not None
      conv = _create_converter_from_pandas(
          MapType(StringType(), StructType().add("a", IntegerType()))
      )
      pser = pd.Series(
          [
              {"x": Row(a=1), "y": Row(a=2), "z": None, None: Row(a=3)},
              {"x": Row(a=4), "y": None, None: Row(a=5)},
              None,
          ]
      )
      assert_series_equal(
          conv(pser),
          pd.Series(
              [
                  [
                      ("x", {"a": 1}),
                      ("y", {"a": 2}),
                      ("z", None),
                      (None, {"a": 3}),
                  ],
                  [("x", {"a": 4}), ("y", None), (None, {"a": 5})],
                  None,
              ]
          ),
      )
  
      # _key_conv is None and _value_conv is not None
      conv = _create_converter_from_pandas(
          MapType(StructType().add("a", StringType()), IntegerType())
      )
      pser = pd.Series(
          [
              {Row(a="x"): 1, Row(a="y"): 2, Row(a="z"): None, None: 3},
              {Row(a="x"): 4, Row(a="y"): None, None: 5},
              None,
          ]
      )
      assert_series_equal(
          conv(pser),
          pd.Series(
              [
                  [
                      ({"a": "x"}, 1),
                      ({"a": "y"}, 2),
                      ({"a": "z"}, None),
                      (None, 3),
                  ],
                  [({"a": "x"}, 4), ({"a": "y"}, None), (None, 5)],
                  None,
              ]
          ),
      )
  
      # ignore_unexpected_complex_type_values=True
  
      # _key_conv is None and _value_conv is None
      conv = _create_converter_from_pandas(
          MapType(StringType(), IntegerType()),
          ignore_unexpected_complex_type_values=True,
      )
      pser = pd.Series(
          [
              {"x": 1, "y": 2, "z": None, None: 3},
              {"x": 4, "y": None, None: 5},
              None,
              100,
          ]
      )
      assert_series_equal(
          conv(pser),
          pd.Series(
              [
                  [("x", 1), ("y", 2), ("z", None), (None, 3)],
                  [("x", 4), ("y", None), (None, 5)],
                  None,
                  100,
              ]
          ),
      )
  
      # _key_conv is None and _value_conv is not None
      conv = _create_converter_from_pandas(
          MapType(StringType(), StructType().add("a", IntegerType())),
          ignore_unexpected_complex_type_values=True,
      )
      pser = pd.Series(
          [
              {"x": Row(a=1), "y": Row(a=2), "z": None, None: Row(a=3)},
              {"x": Row(a=4), "y": None, None: Row(a=5)},
              None,
              100,
          ]
      )
      assert_series_equal(
          conv(pser),
          pd.Series(
              [
                  [
                      ("x", {"a": 1}),
                      ("y", {"a": 2}),
                      ("z", None),
                      (None, {"a": 3}),
                  ],
                  [("x", {"a": 4}), ("y", None), (None, {"a": 5})],
                  None,
                  100,
              ]
          ),
      )
  
      # _key_conv is None and _value_conv is not None
      conv = _create_converter_from_pandas(
          MapType(StructType().add("a", StringType()), IntegerType()),
          ignore_unexpected_complex_type_values=True,
      )
      pser = pd.Series(
          [
              {Row(a="x"): 1, Row(a="y"): 2, Row(a="z"): None, None: 3},
              {Row(a="x"): 4, Row(a="y"): None, None: 5},
              None,
              100,
          ]
      )
      assert_series_equal(
          conv(pser),
          pd.Series(
              [
                  [
                      ({"a": "x"}, 1),
                      ({"a": "y"}, 2),
                      ({"a": "z"}, None),
                      (None, 3),
                  ],
                  [({"a": "x"}, 4), ({"a": "y"}, None), (None, 5)],
                  None,
                  100,
              ]
          ),
      )
  
file_path: spark/python/pyspark/sql/tests/pandas/test_converter.py
imports: import unittest
  from typing import cast
  from pyspark.sql.types import ArrayType, IntegerType, MapType, StringType, StructType, Row
  from pyspark.testing.sqlutils import have_pandas, have_pyarrow, pandas_requirement_message, pyarrow_requirement_message
label_desc: Use image node_id 4 for calling the ConverterTests obj's underlying member method code with example usage: obj.test_converter_from_pandas_map() without return types