Feature Type

  • [ ] Adding new functionality to pandas

  • [X] Changing existing functionality in pandas

  • [ ] Removing existing functionality in pandas

Problem Description

Right now the repr only shows the categories and if they are ordered, but since we can back Categoricals with arrow or nullable dtypes or generally different NumPy dtypes (e.g. int32) we should also show the dtype of the categories:

ser1 = Series(pd.Categorical(Index([1, 2, 3], dtype="int32")))
ser2 = Series(pd.Categorical(Index([1, 2, 3], dtype="int64")))

tm.assert_series_equal(ser1, ser2)

This shows

Attribute "dtype" are different
[left]:  CategoricalDtype(categories=[1, 2, 3], ordered=False)
[right]: CategoricalDtype(categories=[1, 2, 3], ordered=False)

which is not very helpful.

Feature Description

Add something like category_dtype="int32" to the repr.

Alternative Solutions

Not sure what you could do apart from checking explicitly for the categories dtype yourself.

Additional Context

No response

Comment From: mroeschke

+1 to add the dtype information

Comment From: topper-123

+1 from me also.