-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
DOC: explain the mode.chained_assignment
option
#18635
DOC: explain the mode.chained_assignment
option
#18635
Conversation
doc/source/indexing.rst
Outdated
|
||
You can control the action of a chained assignment via the option ``mode.chained_assignment``, | ||
which can take the values ``['raise','warn',None]``, where showing a warning is the default. | ||
When using chained indexing, the order may determine whether a copy is returned |
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.
say 'order of evaluation'
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 agree that merely 'the order' is not explicit enough. Now that I am looking closer, though, I would say it's not the order of evaluation, but the order in which the user chains the indexing operations (which in turn determines the order the operations are evaluated).
I have turned the sentence into this, which I hope is also in the spirit of your edit:
When you use chained indexing, the order and type of the indexing operation
partially determine whether the result is a slice into the original object, or
a copy of the slice.
What do you think of that? I don't mean to make this a bikeshedding point, so I will implement whatever you suggest as the final version.
doc/source/indexing.rst
Outdated
|
||
Pandas has the ``SettingWithCopyWarning`` because assigning to a copy of a | ||
slice is frequently not intentional, but a mistake caused by chained indexing | ||
returning a copy where a slice was expected. If you would like pandas to be |
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.
paragraph break after first sentence
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.
Done.
doc/source/indexing.rst
Outdated
slice is frequently not intentional, but a mistake caused by chained indexing | ||
returning a copy where a slice was expected. If you would like pandas to be | ||
more or less trusting about assignment to a chained indexing expression, you | ||
can set the :ref:`option <options>` ``mode.chained_assignment``, which can take |
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 a bulleted list for these options
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.
Done.
Codecov Report
@@ Coverage Diff @@
## master #18635 +/- ##
==========================================
- Coverage 91.59% 91.57% -0.02%
==========================================
Files 155 155
Lines 51255 51255
==========================================
- Hits 46948 46939 -9
- Misses 4307 4316 +9
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #18635 +/- ##
==========================================
- Coverage 91.59% 91.54% -0.05%
==========================================
Files 153 153
Lines 51257 51210 -47
==========================================
- Hits 46949 46882 -67
- Misses 4308 4328 +20
Continue to review full report at Codecov.
|
3f22934
to
054c048
Compare
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.
lgtm. minor change. ping on green.
doc/source/indexing.rst
Outdated
which can take the values ``['raise','warn',None]``, where showing a warning is the default. | ||
* ``'raise'`` means pandas will raise a ``SettingWithCopyException`` exception | ||
you have to deal with. | ||
* ``'warn'``, the default, means a ``SettingWithCopyWarning`` is printed. |
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.
put the default first
054c048
to
dddb85e
Compare
@jreback I've put the default first, and the checks have passed. Does 'ping on green' mean to send you a message when this is done? If yes, this is your ping. I forgot to say this last time I replied, so I'll say it now: thank you very much! Not just for the review, but for all the work you do for the pandas project. It is very much appreciated. |
@sietse Thanks a lot! (I fixed the conflict, due to another PR that was just merged) |
git diff upstream/master -u -- "*.py" | flake8 --diff
Make the explanation of the
mode.chained_assignment
option link to the explanation of chained indexing and assignment. Explain what the three possible settings do.