-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
CLN: Replacing %s with .format in pandas/core/frame.py #20461
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
CLN: Replacing %s with .format in pandas/core/frame.py #20461
Conversation
AaronCritchley
commented
Mar 22, 2018
- Progress towards CLN: replace %s formatting syntax with .format #16130
- tests added / passed
- passes git diff upstream/master -u -- "*.py" | flake8 --diff
looks good. circle ci seems to be failing. |
…n-16130-core-frame
Codecov Report
@@ Coverage Diff @@
## master #20461 +/- ##
=======================================
Coverage 91.84% 91.84%
=======================================
Files 153 153
Lines 49295 49295
=======================================
Hits 45274 45274
Misses 4021 4021
Continue to review full report at Codecov.
|
Merged in master and pushed. @AaronCritchley let us know if you notice that the CI all passes. |
pandas/core/frame.py
Outdated
@@ -7575,4 +7589,4 @@ def _from_nested_dict(data): | |||
|
|||
|
|||
def _put_str(s, space): | |||
return ('%s' % s)[:space].ljust(space) | |||
return '{s}'.format(s=s)[:space].ljust(space) |
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.
Hey @TomAugspurger, thanks for merging in master, it looks like CI is failing here when given a unicode value for s:
s = 'σ', space = 5
def _put_str(s, space):
> return '{s}'.format(s=s)[:space].ljust(space)
E UnicodeEncodeError: 'ascii' codec can't encode character u'\u03c3' in position 0: ordinal not in range(128)
I'm not sure on how Pandas approaches unicode and what the preferred way of solving is, I'm happy to implement something but would rather make sure it's in the Pandas style.
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.
To clarify, not at my laptop atm but I have a feeling just making this:
u'{s}'.format(s=s)[:space].ljust(space)
would fix it, but it doesn't seem consistent with other .format occurrences, this could all be from a lack of understanding of how Pandas generally handles unicode though.
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 u
prefix is appropriate here.
thanks! |