Skip to content

Commit 7a8694c

Browse files
authored
Update v2.2.0.rst
1 parent 283488f commit 7a8694c

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

doc/source/whatsnew/v2.2.0.rst

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -97,26 +97,6 @@ This future dtype inference logic can be enabled with:
9797
Enhancements
9898
~~~~~~~~~~~~
9999

100-
.. _whatsnew_220.enhancements.case_when:
101-
102-
Create a pandas Series based on one or more conditions
103-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
104-
105-
The :func:`case_when` function has been added to create a Series object based on one or more conditions. (:issue:`39154`)
106-
107-
.. ipython:: python
108-
109-
import pandas as pd
110-
111-
df = pd.DataFrame(dict(a=[1, 2, 3], b=[4, 5, 6]))
112-
default=pd.Series('default', index=df.index)
113-
default.case_when(
114-
caselist=[
115-
(df.a == 1, 'first'), # condition, replacement
116-
(df.a.gt(1) & df.b.eq(5), 'second'), # condition, replacement
117-
],
118-
)
119-
120100
.. _whatsnew_220.enhancements.adbc_support:
121101

122102
ADBC Driver support in to_sql and read_sql
@@ -208,6 +188,26 @@ For a full list of ADBC drivers and their development status, see the `ADBC Driv
208188
Implementation Status <https://arrow.apache.org/adbc/current/driver/status.html>`_
209189
documentation.
210190

191+
.. _whatsnew_220.enhancements.case_when:
192+
193+
Create a pandas Series based on one or more conditions
194+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
195+
196+
The :func:`case_when` function has been added to create a Series object based on one or more conditions. (:issue:`39154`)
197+
198+
.. ipython:: python
199+
200+
import pandas as pd
201+
202+
df = pd.DataFrame(dict(a=[1, 2, 3], b=[4, 5, 6]))
203+
default=pd.Series('default', index=df.index)
204+
default.case_when(
205+
caselist=[
206+
(df.a == 1, 'first'), # condition, replacement
207+
(df.a.gt(1) & df.b.eq(5), 'second'), # condition, replacement
208+
],
209+
)
210+
211211
.. _whatsnew_220.enhancements.to_numpy_ea:
212212

213213
``to_numpy`` for NumPy nullable and Arrow types converts to suitable NumPy dtype

0 commit comments

Comments
 (0)