Skip to content

Commit 67ac0a0

Browse files
committed
Simplify phrasing
1 parent d47ebd1 commit 67ac0a0

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

doc/source/user_guide/indexing.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,18 +1167,19 @@ An alternative to :meth:`~pandas.DataFrame.where` is to use :func:`numpy.where`.
11671167
Combined with setting a new column, you can use it to enlarge a dataframe where the
11681168
values are determined conditionally.
11691169

1170-
When you have two choices to choose from, say in the following dataframe, set the color
1171-
to 'green' when the second column has 'Z'. You can do the following:
1170+
Consider you have two choices to choose from in the following dataframe. And you want to
1171+
set a new column color to 'green' when the second column has 'Z'. You can do the
1172+
following:
11721173

11731174
.. ipython:: python
11741175
11751176
df = pd.DataFrame({'col1': list('ABBC'), 'col2': list('ZZXY')})
11761177
df['color'] = np.where(df['col2'] == 'Z', 'green', 'red')
11771178
df
11781179
1179-
If you have more than one conditions, you can use :func:`numpy.select` to achieve that.
1180-
Say corresponding to three conditions there are three choice of colors, with a fourth
1181-
color as a fallback, you can do the following.
1180+
If you have multiple conditions, you can use :func:`numpy.select` to achieve that. Say
1181+
corresponding to three conditions there are three choice of colors, with a fourth color
1182+
as a fallback, you can do the following.
11821183

11831184
.. ipython:: python
11841185

0 commit comments

Comments
 (0)