-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: repr of Categorical does not distinguish int and str. #34222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
aaf4e42
quote string elements
MarcoGorelli 1f90a62
wip
MarcoGorelli 5a93a67
wip
MarcoGorelli 4cef20c
Merge remote-tracking branch 'upstream/master' into cat-rep
MarcoGorelli a3c6eda
wip
MarcoGorelli 9277d38
remove vscode failures
MarcoGorelli b978bf9
merge error
MarcoGorelli 3215936
quotestring
MarcoGorelli e6ce96f
only quote categorical
MarcoGorelli 197038b
fix some failing tests due to changes
MarcoGorelli f594fa1
whatsnew
MarcoGorelli 4912ec3
set quote strings to boolean
MarcoGorelli 79dd24b
Merge remote-tracking branch 'upstream/master' into cat-rep
MarcoGorelli d57ae96
fix doctest
MarcoGorelli aa62a24
move whatsnew section, use partial, always quotenonnumeric in categor…
MarcoGorelli 9562313
docstrings
MarcoGorelli 457abe3
fix failing doctests
MarcoGorelli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GenericArrayFormatter has a
quoting
parameter. format_array does not have this parameter to be able to pass it on._repr_categories
inpandas\core\arrays\categorical.py
usesformat_array
.is it feasible to add
quoting
parameter to format_array instead of changing this?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@simonjayhawkins thanks for the suggestion!
So, in
_repr_categories
frompandas\core\arrays\categorical.py
,format_array
is called. This could be changed to, say,and then, inside
format_array
, passquoting
on tofmt_klass
, so that (here)GenericArrayFormatter
would be initialised with it.It's unclear to me me what
GenericArrayFormatter
currently does withquoting
, I don't see it being used. Should there be no need to change anything here in_format_strings
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that does seem strange, I must have assumed wrongly where the quoting parameter is used. will look again, but your suggestions sgtm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of this you need to adjust _format, L1221; you maybe able to simply adjust the args to pprint_thing which can quote as needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thanks for pointing me towards that, that was useful!
So,
pprint_thing
takes aquote_string
argument, which is boolean, whilequoting
isOptional[int]
, so I've tried doing this by settingand then passing
quote_strings
topprint_thing