-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: na_rep given precedence in to_html #13911
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
# na_rep takes precedence over the specified formatter | ||
if self.na_rep is not None: | ||
return np.array([self.formatter(x) if notnull(x) | ||
else self.na_rep for x in self.values]) |
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.
use notnull on the entire array first to create a mask
format the non null values then fill the nans
see the datetime formatters for how to do this
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.
@jreback I just looked at the datetime formatters but I don't know what you mean. Could you be more explicit? Thanks.
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.
like this (from internals.py)
def to_native_types(self, slicer=None, na_rep=None, quoting=None,
**kwargs):
""" convert to our native types format, slicing if desired """
values = self.values
if slicer is not None:
values = values[:, slicer]
mask = isnull(values)
rvalues = np.empty(values.shape, dtype=object)
if na_rep is None:
na_rep = 'NaT'
rvalues[mask] = na_rep
imask = (~mask).ravel()
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.
See update. Is that what you mean?
Current coverage is 84.64% (diff: 90.00%)@@ master #13911 diff @@
==========================================
Files 144 144
Lines 51016 51024 +8
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 43184 43191 +7
- Misses 7832 7833 +1
Partials 0 0
|
@jreback I think I understood what you meant by iterating over non-null values. Please have a look. |
can you rebase / update? |
Rebased and all green. |
lgtm. @jorisvandenbossche |
@@ -2060,7 +2060,19 @@ def get_result_as_array(self): | |||
""" | |||
|
|||
if self.formatter is not None: | |||
return np.array([self.formatter(x) for x in self.values]) | |||
if self.na_rep is 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.
you are repeating lots of code from right below format_values_with
. see if you can simplify
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.
can you update here
@@ -1524,6 +1524,7 @@ Bug Fixes | |||
- Bug in ``groupby(..).nth()`` where the group key is included inconsistently if called after ``.head()/.tail()`` (:issue:`12839`) | |||
- Bug in ``.to_html``, ``.to_latex`` and ``.to_string`` silently ignore custom datetime formatter passed through the ``formatters`` key word (:issue:`10690`) | |||
- Bug in ``DataFrame.iterrows()``, not yielding a ``Series`` subclasse if defined (:issue:`13977`) | |||
- Bug in ``.to_html``, ``.to_latex`` and ``.to_string`` ignoring ``na_rep`` in the presence of a ``float_format`` function. (:issue:`13911`) |
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.
can you move to 0.20.0
i think this got lost in the shuffle, can you update. |
Rebased, moved whatsnew to 0.20.0, need to look into the code duplication @jreback mentioned. |
can you rebase / update |
closing as stale. please ping if you'd like to continue. |
git diff upstream/master | flake8 --diff
I know new tests are appreciated from the get-go, but it's the end of the day for me. I'll add new tests and the appropriate whatsnew entry tomorrow.