Closed
Description
Location of the documentation
https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#evaluation-order-matters
Documentation problem
The documentation talks about how not to use dfb['c'][dfb['a'].str.startswith('o')] = 42
for assignment of multiple values to a pandas.Series
or pandas.DataFrame
column. it does however fail to make a concrete suggestion how to do it given the example.
Suggested fix for documentation
I suggest to mention the pandas.Series.where
and pandas.Series.mask
methods here in order to show how the assignment can be done, i.e. by adding an example like:
dfb['c'].mask(dfb['a'].str.startswith('o'), 42)
which performs the desired assigment of rows matching o
to 42
. I am happy to contribute this as a PR myself.