code: def test_unionize_dataframe_categories(
      uniontest_df1, uniontest_df2, uniontest_df3
  ):
      udf1, udf2, udf3 = janitor.unionize_dataframe_categories(
          uniontest_df1, uniontest_df2, uniontest_df3
      )
  
      # test categories were unioned properly
  
      assert set(udf1["jerbs"].dtype.categories) == set(
          udf2["jerbs"].dtype.categories
      )
  
      assert set(udf1["jerbs"].dtype.categories) == set(
          udf3["jerbs"].dtype.categories
      )
  
      assert set(udf1["fruits"].dtype.categories) == set(
          udf3["fruits"].dtype.categories
      )
  
      assert set(udf1["fruits"].dtype.categories) == set(
          udf3["fruits"].dtype.categories
      )
  
      assert set(udf2["animals"].dtype.categories) == set(
          udf3["animals"].dtype.categories
      )
  
      # test columns did not bleed in
  
      assert "df2_exclusive" not in udf1.columns
      assert "df2_exclusive" not in udf3.columns
      assert "df1_exclusive" not in udf2.columns
      assert "df1_exclusive" not in udf3.columns
      assert "df3_exclusive" not in udf1.columns
      assert "df3_exclusive" not in udf2.columns
  
      assert "animals" not in udf1.columns
  
      # test that pd.concat now does not destroy categoricals
  
      # NOTE: 'animals' column will not be preserved as categorical after concat
      # because it is not present in df1. Instead, this column will be set to
      # object with NaN filled in for df1 missing values.
  
      udf = pd.concat([udf1, udf2, udf3], ignore_index=True)
  
      assert isinstance(udf["jerbs"].dtype, pd.CategoricalDtype)
      assert isinstance(udf["fruits"].dtype, pd.CategoricalDtype)
  
      # test that the data is the same
  
      assert_frame_equal(udf1, uniontest_df1, check_categorical=False)
      assert_frame_equal(udf2, uniontest_df2, check_categorical=False)
      assert_frame_equal(udf3, uniontest_df3, check_categorical=False)
  
file_path: pyjanitor/tests/functions/test_unionize_dataframe_categories.py
imports: import pandas
  import pytest
  from pandas.testing import assert_frame_equal
  import janitor
label_desc: Use image node_id 5 for calling a global function with example usage: test_unionize_dataframe_categories(uniontest_df1, uniontest_df2, uniontest_df3) without return types