BUG: fix padding for string categories in CategoricalIndex repr
State: closed

Resolving some xfails: getting back the same padding as we had before.

On current main with string dtype:
```
>>> pd.CategoricalIndex(["a", "bb", "ccc"] * 10)
CategoricalIndex([  'a',  'bb', 'ccc',   'a',  'bb', 'ccc',   'a',  'bb',
                  'ccc',   'a',  'bb', 'ccc',   'a',  'bb', 'ccc',   'a',
                   'bb', 'ccc',   'a',  'bb', 'ccc',   'a',  'bb', 'ccc',
                    'a',  'bb', 'ccc',   'a',  'bb', 'ccc'],
                 categories=['a', 'bb', 'ccc'], ordered=False, dtype='category')
```

With this PR and what it looks like with object dtype:

```
>>> pd.CategoricalIndex(["a", "bb", "ccc"] * 10)
CategoricalIndex(['a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a',
                  'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb',
                  'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc'],
                 categories=['a', 'bb', 'ccc'], ordered=False, dtype='category')
```


Labels:
name: Bug
name: Output-Formatting
description: __repr__ of pandas objects, to_string

Comments:
On second look, I retract my claim that the old padding is nicer. No preference.
I think the non-aligned version (so how it was before / is with object dtype) is better, especially for cases where your categories have different length. The example here only has 1 vs 3 characters, but for example:

```
# on main with str dtype / without this PR
>>> pd.CategoricalIndex(["low", "intermediate", "high", "low"] * 10)
CategoricalIndex([         'low', 'intermediate',         'high',
                           'low',          'low', 'intermediate',
                          'high',          'low',          'low',
                  'intermediate',         'high',          'low',
                           'low', 'intermediate',         'high',
                           'low',          'low', 'intermediate',
                          'high',          'low',          'low',
                  'intermediate',         'high',          'low',
                           'low', 'intermediate',         'high',
                           'low',          'low', 'intermediate',
                          'high',          'low',          'low',
                  'intermediate',         'high',          'low',
                           'low', 'intermediate',         'high',
                           'low'],
                 categories=[high, intermediate, low], ordered=False, dtype='category')

```

vs 

```
# with object dtype / with str dtype with this PR
>>> pd.CategoricalIndex(["low", "intermediate", "high", "low"] * 10)
CategoricalIndex(['low', 'intermediate', 'high', 'low', 'low', 'intermediate',
                  'high', 'low', 'low', 'intermediate', 'high', 'low', 'low',
                  'intermediate', 'high', 'low', 'low', 'intermediate', 'high',
                  'low', 'low', 'intermediate', 'high', 'low', 'low',
                  'intermediate', 'high', 'low', 'low', 'intermediate', 'high',
                  'low', 'low', 'intermediate', 'high', 'low', 'low',
                  'intermediate', 'high', 'low'],
                 categories=['high', 'intermediate', 'low'], ordered=False, dtype='category')
```

Of course this can also happen with non-strings like integers, but I think it is a lot less common