code: def convert_pandas_type_to_json_field(arr, dtype=None):
      dtype = dtype or arr.dtype
      if arr.name is None:
          name = "values"
      else:
          name = arr.name
      field = {"name": name, "type": as_json_table_type(dtype)}
  
      if is_categorical_dtype(arr):
          if hasattr(arr, "categories"):
              cats = arr.categories
              ordered = arr.ordered
          else:
              cats = arr.cat.categories
              ordered = arr.cat.ordered
          field["constraints"] = {"enum": list(cats)}
          field["ordered"] = ordered
      elif is_period_dtype(arr):
          field["freq"] = arr.freqstr
      elif is_datetime64tz_dtype(arr):
          if hasattr(arr, "dt"):
              field["tz"] = arr.dt.tz.zone
          else:
              field["tz"] = arr.tz.zone
      return field
  
file_path: catboost/contrib/python/pandas/py2/pandas/io/json/table_schema.py
imports: import warnings
  import pandas._libs.json
  from pandas.core.dtypes.common import is_bool_dtype, is_categorical_dtype, is_datetime64_dtype, is_datetime64tz_dtype, is_integer_dtype, is_numeric_dtype, is_period_dtype, is_string_dtype, is_timedelta64_dtype
  from pandas import DataFrame
  from pandas.api.types import CategoricalDtype
  import pandas.core.common
label_desc: Use image node_id 3 for calling a global function with example usage: convert_pandas_type_to_json_field(arr, dtype) and returns: field