-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: CategoricalIndex.format #35440
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
BUG: CategoricalIndex.format #35440
Conversation
Thanks @topper-123 for the PR. The regression was caused by #35118. Categorical types other than object were also affected. maybe need to parameterise test with other values for
doc\source\whatsnew\v1.1.1.rst now merged to master |
eb920f9
to
cd8a9ee
Compare
@@ -197,9 +197,6 @@ def _format_data(self, name=None): | |||
# we are formatting thru the attributes | |||
return None | |||
|
|||
def _format_with_header(self, header, na_rep="NaN") -> List[str]: | |||
return header + [pprint_thing(x) for x in self._range] | |||
|
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.
The added tests revealed that this method in master made the output from RangeIndex.format
different than for Int64Index.format
:
>>> pd.RangeIndex(0, 18, 2).format()
['0', '2', '4', '6', '8', '10', '12', '14', '16']
>>> pd.Int64Index(range(0, 18, 2)).format()
['0 ', '2 ', '4 ', '6 ', '8 ', '10', '12', '14', '16']
Notice the extra space for one-digit scalars in the Int64Index
case. The outputs from the two methods are identical after merging this PR.
Updated. |
thanks @topper-123 very nice! |
@meeseeksdev backport to 1.1.x |
Co-authored-by: Terji Petersen <[email protected]>
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
I've temporarily put the whatsnewentry in the v.1.1.0 release note, because there isn't a v.1.1.1 version yet. I'll move it, before this is merged.