Open h-vetinari opened 6 years ago
The return type here is part of the documentation (though perhaps could be improved):
https://pandas.pydata.org/pandas-docs/stable/categorical.html#string-and-datetime-accessors
FWIW I don't really see how you could return a Categorical after a concatenation and make guarantees about the returned metadata (ordering comes to mind here). IMO doing concat on a large array of values would in most cases generate a ton of unique values and defeat the purpose of a Categorical in the first place.
@WillAyd
Thanks for that reference in the docs (had seen it only in individual doc-strings). However, I don't think it's fair to assume what kind of data would result - I can imagine several cases where this would be sensible. I still find something worth considering, but at least there's an easy solution with .astype('category')
.
The
str.cat
-accessor works for Series and Index, and returns an object of the corresponding type:But the data loses its property of being a category after
str.cat
, which is inconsistent, IMOxref #20842 #20843