Skip to content

Commit 7292a08

Browse files
committed
DOC: more info for dtype argument of get_dummies in whatsnew
1 parent 579d498 commit 7292a08

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

doc/source/whatsnew/v0.22.0.txt

+21
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,27 @@ Other Enhancements
2727
- :class:`pandas.io.formats.style.Styler` now has method ``hide_index()`` to determine whether the index will be rendered in ouptut (:issue:`14194`)
2828
- :class:`pandas.io.formats.style.Styler` now has method ``hide_columns()`` to determine whether columns will be hidden in output (:issue:`14194`)
2929

30+
``get_dummies`` now supports ``dtype`` argument
31+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
32+
33+
: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`)
34+
35+
**Previous behavior**:
36+
37+
.. ipython:: python
38+
39+
df = pd.DataFrame({'a': [1, 2], 'b': [3, 4], 'c': [5, 6]})
40+
pd.get_dummies(df, columns=['c'])
41+
42+
**New behavior**:
43+
44+
.. ipython:: python
45+
46+
df = pd.DataFrame({'a': [1, 2], 'b': [3, 4], 'c': [5, 6]})
47+
pd.get_dummies(df, columns=['c'])
48+
pd.get_dummies(df, columns=['c'], dtype=bool)
49+
pd.get_dummies(df, columns=['c'], dtype=np.float64)
50+
3051
.. _whatsnew_0220.api_breaking:
3152

3253
Backwards incompatible API changes

0 commit comments

Comments
 (0)