code: def test_categorical_code_conversion_doesnt_modify_original_data(
      feature_name, categories
  ):
      pd = pytest.importorskip("pandas")
      X = np.random.choice(["a", "b"], 100).reshape(-1, 1)
      column_name = "a" if feature_name == "auto" else feature_name[0]
      df = pd.DataFrame(
          X.copy(), columns=[column_name], dtype="category"
      )
      if categories == "seen":
          pandas_categorical = [["a", "b"]]
      else:
          pandas_categorical = [["a"]]
      data = lgb.basic._data_from_pandas(
          data=df,
          feature_name=feature_name,
          categorical_feature="auto",
          pandas_categorical=pandas_categorical,
      )[0]
      # check that the original data wasn't modified
      np.testing.assert_equal(df[column_name], X[:, 0])
      # check that the built data has the codes
      if categories == "seen":
          # if all categories were seen during training we just take the codes
          codes = df[column_name].cat.codes
      else:
          # if we only saw 'a' during training we just replace its code
          # and leave the rest as nan
          a_code = df[column_name].cat.categories.get_loc("a")
          codes = np.where(df[column_name] == "a", a_code, np.nan)
      np.testing.assert_equal(codes, data[:, 0])
  
imports: import filecmp
  import numbers
  import re
  from copy import deepcopy
  from os import getenv
  from pathlib import Path
  import numpy
  import pytest
  from scipy import sparse
  from sklearn.datasets import dump_svmlight_file, load_svmlight_file
  from sklearn.model_selection import train_test_split
  import lightgbm
  from lightgbm.compat import PANDAS_INSTALLED, pd_DataFrame, pd_Series
  from .utils import dummy_obj, load_breast_cancer, mse_obj, np_assert_array_equal
label_desc: Use image node_id 30 for calling a global function with example usage: test_categorical_code_conversion_doesnt_modify_original_data(feature_name, categories) without return types