Description
Is your feature request related to a problem?
Sometimes, it is useful for debugging to be able to see the contents of a Series with repr()
instead of str()
applied to each element.
Specifically with strings, it is often useful to see non-ASCII Unicode characters escaped, and to see the surrouning quotation marks, to detect whitespace at the start and end.
Another use case might be some situation where you have other nontrivial object
s in a Series, and their str
representations are somehow less useful than their repr
representations.
For example, print(pd.Series(['a', 'b', 'c'], dtype='string'))
yields:
0 a
1 b
2 c
dtype: string
But it would be helpful if it could yield:
0 'a'
1 'b'
2 'c'
dtype: string
Describe the solution you'd like
One possibility is a new module option, maybe display.string_as_repr
(just for strings) or display.print_as_repr
(for all non-numeric entries), to enable this behavior.
API breaking implications
None that I know of.
Describe alternatives you've considered
You could use .apply(repr)
or similar, to see this output in an ad-hoc way.
Additional context
This was originally a StackOverflow question: https://stackoverflow.com/q/71832297/2954547