-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DOC: clarify "inplace"-ness of DataFrame.setitem #51328
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
Changes from 1 commit
3a597f4
ec260fc
bfda14c
87b454d
f267346
85b9a77
8805f78
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3867,23 +3867,26 @@ def _get_value(self, index, col, takeable: bool = False) -> Scalar: | |
|
||
def isetitem(self, loc, value) -> None: | ||
""" | ||
Set the given value in the column with position 'loc'. | ||
Set the given value in the column with position `loc`. | ||
|
||
This is a positional analogue to __setitem__. | ||
This is a positional analogue to `__setitem__`. | ||
|
||
Parameters | ||
---------- | ||
loc : int or sequence of ints | ||
Index position for the column. | ||
value : scalar or arraylike | ||
Value(s) for the column. | ||
|
||
Notes | ||
----- | ||
Unlike `frame.iloc[:, i] = value`, `frame.isetitem(loc, value)` will | ||
_never_ try to set the values in place, but will always insert a new | ||
array. | ||
``frame.isetimtem(loc, value)`` is an in-place method as it will | ||
modify the frame in place (not returning a new object) but it will | ||
loicdiridollou marked this conversation as resolved.
Show resolved
Hide resolved
|
||
not update the values of the column itself, it will instead insert | ||
loicdiridollou marked this conversation as resolved.
Show resolved
Hide resolved
|
||
a new array. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would add something like "in contrast to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just made some examples on my side and indeed this is quite important to keep that in the docs, I will update that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should be good now, let me know if the phrasing is clear enough There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should be good now, let me know if the phrasing is clear enough |
||
|
||
In cases where `frame.columns` is unique, this is equivalent to | ||
`frame[frame.columns[i]] = value`. | ||
In cases where ``frame.columns`` is unique, this is equivalent to | ||
``frame[frame.columns[i]] = value``. | ||
""" | ||
if isinstance(value, DataFrame): | ||
if is_scalar(loc): | ||
|
Uh oh!
There was an error while loading. Please reload this page.