Description
Is your feature request related to a problem?
When displaying dataframes that contain IntEnums in the index, columns, or data, it would be nice if they displayed similar to Enum types by using the Enum names that correspond to the value rather then the integer values, which somewhat defeats the prupose of using IntEnums over just ints with alias names.
Describe the solution you'd like
I would like pandas to display IntEnums in the same way as Enums.
API breaking implications
Non that I am aware of, as this request is only for a display change.
Describe alternatives you've considered
I have considered two solution which both have drawbacks. First was to monkey patch Int Array Formatter. This ended up not working as Pandas appears to case IntEnums to regulat ints as soon as they are put into the frame. The second was to change the IntEnums to be categorical, which makes logical sense, but to get them to display properly I need to map the data to the names of the enums which changes the underlying data to strings.
Additional context
Here is a simple example.
from enum import Enum, IntEnum
import pandas as pd
class Colors(Enum):
red = 1
blue = 2
class IntColors(IntEnum):
red = 1
blue = 2
df = pd.DataFrame({Colors.red:[1,2,3], Colors.blue:[5,6,6]})
int_df = pd.DataFrame({IntColors.red:[1,2,3], IntColors.blue:[5,6,6]})
print('This is how I want the dataframe to display')
print(df)
print()
print('This is how it is displayed')
print(int_df)
Which outputs:
This is how I want the dataframe to display
Colors.red Colors.blue
0 1 5
1 2 6
2 3 6
This is how it is displayed
1 2
0 1 5
1 2 6
2 3 6