Skip to content

Commit a1de373

Browse files
committed
DOC: add get_dummies dtype argument description to reshaping.rst
1 parent f39f015 commit a1de373

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

doc/source/reshaping.rst

+12-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ values will be set to ``NaN``.
240240
df3
241241
df3.unstack()
242242
243-
.. versionadded: 0.18.0
243+
.. versionadded:: 0.18.0
244244

245245
Alternatively, unstack takes an optional ``fill_value`` argument, for specifying
246246
the value of missing data.
@@ -634,6 +634,17 @@ When a column contains only one level, it will be omitted in the result.
634634
635635
pd.get_dummies(df, drop_first=True)
636636
637+
By default new columns will have ``np.uint8`` dtype. To choose another dtype use ``dtype`` argument:
638+
639+
.. ipython:: python
640+
641+
df = pd.DataFrame({'A': list('abc'), 'B': [1.1, 2.2, 3.3]})
642+
643+
pd.get_dummies(df, dtype=bool).dtypes
644+
645+
.. versionadded:: 0.22.0
646+
647+
637648
.. _reshaping.factorize:
638649

639650
Factorizing values

pandas/core/reshape/reshape.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ def get_dummies(data, prefix=None, prefix_sep='_', dummy_na=False,
729729
.. versionadded:: 0.18.0
730730
731731
dtype : dtype, default np.uint8
732-
Data type to force on a new columns. Only a single dtype is allowed.
732+
Data type for new columns. Only a single dtype is allowed.
733733
734734
.. versionadded:: 0.22.0
735735

0 commit comments

Comments
 (0)