-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: do not replace all nulls with "NaN"-string in Series index #45283
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
Conversation
The question is what to do about DataFrame?
leads to
It probably should behave the same way Series behaves? |
yes |
After the change np.nan is printed as "nan". Probably we would like to keep "NaN"? |
pandas/io/formats/format.py
Outdated
@@ -366,10 +366,10 @@ def _get_formatted_index(self) -> tuple[list[str], bool]: | |||
|
|||
if isinstance(index, MultiIndex): | |||
have_header = any(name for name in index.names) | |||
fmt_index = index.format(names=True) | |||
fmt_index = index.format(names=True, na_rep=None) |
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.
i think we need to correctly format floats with NaN
in the indexes itself (if nothing is passed) to have NaN
(rather than nan
). see if that works.
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.
i think we need to correctly format floats with
NaN
in the indexes itself (if nothing is passed) to haveNaN
(rather thannan
). see if that works.
@jreback True, it seems like a better solution now.
There are some test failures now, but it looks like not due to this change (maybe docs - but I don't see what went wrong there).
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.
excellent! yeah let me see what's up with the docs
How can we access values where index is NaN?? |
02eec99
to
12c1c4a
Compare
@realead can you merge master. we fixed the doc links there so let's see |
@jreback it seems to work now. |
@@ -248,6 +248,31 @@ cdef bint checknull_with_nat_and_na(object obj): | |||
return checknull_with_nat(obj) or obj is C_NA | |||
|
|||
|
|||
@cython.wraparound(False) |
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.
ok not super happy we need this but ok. cc @jbrockmendel
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.
thanks @realead
…"-string in Series index
…n Series index (#45473) Co-authored-by: realead <[email protected]>
After this, the example
yields
which is good.
I've kept the behavioral changes minimal, however not sure it is the best way to go.
SeriesFormatter
has ana_rep
(pandas/pandas/io/formats/format.py
Line 280 in b77797c
None
to signal that I don't want any replacing). But why should values be handled differently?pandas/pandas/core/indexes/base.py
Lines 1392 to 1411 in b77797c