-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
ENH/API: GH2578, allow ix and friends to partially set when the key is not contained in the object #4515
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
I guess I wonder what should happen in these kinds of cases cases - any magic? df.loc[5] = 3
s[6] = 5 |
looks good. |
these are straightforward
I have disabled both
|
@wesm take a look? this is non-trivial but you were already going it bith set_value in any event, this just generalizes (and with series refactor this is able to be done in-place, which makes pretty natural) |
any comments before merging? |
…t contained in the object
CLN: set_value in Series/Frame now go thru indexing routings in core/indexing.py
ENH/API: GH2578, allow ix and friends to partially set when the key is not contained in the object
@@ -828,6 +990,9 @@ def _has_valid_type(self, key, axis): | |||
|
|||
return isinstance(key, slice) or com.is_integer(key) or _is_list_like(key) | |||
|
|||
def _has_valid_setitem_indexer(self, indexer): | |||
self._has_valid_positional_setitem_indexer(indexer) |
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 is this supposed to return 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.
no...they will just raise if needed
closes #2578
On a series, this is kind of like an inplace append operation (note the dtype change - on purpose)
This is now allowed: (previously would
KeyError
), you first have to create the columnC
, then set itThis would previously raise an
IndexError
and on Panel: