code: def test_transpose_categorical_data() -> None:
      with pl.StringCache():
          df = pl.DataFrame(
              [
                  pl.Series(["a", "b", "c"], dtype=pl.Categorical),
                  pl.Series(["c", "g", "c"], dtype=pl.Categorical),
                  pl.Series(["d", "b", "c"], dtype=pl.Categorical),
              ]
          )
          df_transposed = df.transpose(
              include_header=False,
              column_names=["col1", "col2", "col3"],
          )
          assert_series_equal(
              df_transposed.get_column("col1"),
              pl.Series("col1", ["a", "c", "d"], dtype=pl.Categorical),
          )
  
      # Without string Cache only works if they have the same categories in the same order
      df = pl.DataFrame(
          [
              pl.Series(["a", "b", "c", "c"], dtype=pl.Categorical),
              pl.Series(["a", "b", "b", "c"], dtype=pl.Categorical),
              pl.Series(["a", "a", "b", "c"], dtype=pl.Categorical),
          ]
      )
      df_transposed = df.transpose(
          include_header=False,
          column_names=["col1", "col2", "col3", "col4"],
      )
  
      with pytest.raises(StringCacheMismatchError):
          pl.DataFrame(
              [
                  pl.Series(["a", "b", "c", "c"], dtype=pl.Categorical),
                  pl.Series(["c", "b", "b", "c"], dtype=pl.Categorical),
              ]
          ).transpose()
  
file_path: polars/py-polars/tests/unit/operations/test_transpose.py
imports: from datetime import date, datetime
  from typing import Iterator
  import pytest
  import polars
  from polars.exceptions import ComputeError, StringCacheMismatchError
  from polars.testing import assert_frame_equal, assert_series_equal
label_desc: Use image node_id 5 for calling a global function with example usage: test_transpose_categorical_data() without return types