-
-
Couldn't load subscription status.
- Fork 19.2k
ENH: Add Index.fillna #11343
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
ENH: Add Index.fillna #11343
Conversation
pandas/tests/test_index.py
Outdated
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.
assert NotImplementedError here
|
Thanks, did the suggested changes. A test fails in |
163b6cc to
c08ac92
Compare
|
Rebased, and now green. |
pandas/core/index.py
Outdated
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 if this catches TypeError as well it can be much more generic
|
Thanks, simplified the logic based on the comments. |
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.
this is override core/base.py, but do we use that anylonger? (I don't think Series uses 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.
I haven't notice base.py. Should remove it from base.py because Series can be changed inplace?
pandas/tseries/index.py
Outdated
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 don't need this any longer once you call _assert_can_do_op in Index.putmask
687ce6a to
bf1f842
Compare
6ea192b to
b20820a
Compare
|
Thanks, updated based on the comments.
|
pandas/tseries/index.py
Outdated
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.
hmm, this seems to be not necessary?
e.g. you are checking if its np.datetime64 below so it will never be the case?
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.
Ah, needs change. This is for current _has_same_tz cannot get tz from np.datetime64.
- move the condition to
_has_same_tz? ( convertnp.datetime64toTimestamp). - If we keep 1594th line, 1598th line can be
if isinstance(item, datetime):
Maybe option 1 looks better?
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.
yeh 1 is better, this might work
vzone = tslib.get_timezone(getattr(Timestamp(other), 'tzinfo', '__no_tz__'))
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.
actually if you always wrap other then you can simply return Timestamp(other).tz I think
(though may be overlooking something)
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.
In _has_same_tz, other can be DTI or list-likes. Thus added if for np.datetime64.
|
@sinhrks looks really good! just a minor comment / question |
|
Reabsed, and now green. |
|
lgtm merge when ready thanks! might want to add s short example in the Index docs (iirc where we go over Index set ops) |
|
Thanks. Added brief doc to |
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 put this above the title?
|
@sinhrks Looks good! One more remark, doc-wise: I see there is a |
|
@sinhrks thanks! always gr8 PR's from you! |
|
I don't see an entry in |
Closes #10089.
valuecan only accept scalar.MultiIndex.fillnaraisesNotImplementedErrorbecauseisnullis not defined for MI.hasnansand related properties to baseIndex.