Skip to content

Commit d89a8a2

Browse files
committed
DOC: more info for dtype argument of get_dummies in whatsnew
1 parent cf33b8c commit d89a8a2

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

doc/source/whatsnew/v0.22.0.txt

+18-8
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,27 @@ Other Enhancements
2424

2525
- Better support for :func:`Dataframe.style.to_excel` output with the ``xlsxwriter`` engine. (:issue:`16149`)
2626
- :func:`pandas.tseries.frequencies.to_offset` now accepts leading '+' signs e.g. '+1h'. (:issue:`18171`)
27-
- :func:`pandas.get_dummies` now supports ``dtype`` argument, which forces specific dtype for new columns. (:issue:`18330`)
2827

29-
.. code-block:: ipython
28+
``get_dummies`` now supports ``dtype`` argument
29+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3030

31-
In [1]: df = pd.DataFrame({'a': [1, 2], 'b': [3, 4], 'c': [5, 6]})
32-
In [2]: pd.get_dummies(df, columns=['c'], dtype=bool)
31+
:func:`get_dummies` function now accepts ``dtype`` argument, which forces specific dtype for new columns. When ``dtype`` is not specified or equals to ``None``, new columns will have dtype ``uint8`` (as before), so this change is backwards compatible. (:issue:`18330`)
3332

34-
Out[1]:
35-
a b c_5 c_6
36-
0 1 3 True False
37-
1 2 4 False True
33+
**Previous behavior**:
34+
35+
.. ipython:: python
36+
37+
df = pd.DataFrame({'a': [1, 2], 'b': [3, 4], 'c': [5, 6]})
38+
pd.get_dummies(df, columns=['c'])
39+
40+
**New behavior**:
41+
42+
.. ipython:: python
43+
44+
df = pd.DataFrame({'a': [1, 2], 'b': [3, 4], 'c': [5, 6]})
45+
pd.get_dummies(df, columns=['c'])
46+
pd.get_dummies(df, columns=['c'], dtype=bool)
47+
pd.get_dummies(df, columns=['c'], dtype=np.float64)
3848

3949
.. _whatsnew_0220.api_breaking:
4050

0 commit comments

Comments
 (0)