From d04cb7e6e3fe506e3282aa5125d0101a55e07dd2 Mon Sep 17 00:00:00 2001 From: Pietro Battiston Date: Thu, 8 Sep 2022 18:08:39 +0200 Subject: [PATCH] DOC: complete documentation for pd.get_dummies (#48466) --- pandas/core/reshape/encoding.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pandas/core/reshape/encoding.py b/pandas/core/reshape/encoding.py index da4de8cc57e65..9567a1053c9a6 100644 --- a/pandas/core/reshape/encoding.py +++ b/pandas/core/reshape/encoding.py @@ -35,6 +35,10 @@ def get_dummies( """ Convert categorical variable into dummy/indicator variables. + Each variable is converted in as many 0/1 variables as there are different + values. Columns in the output are each named after a value; if the input is + a DataFrame, the name of the original variable is prepended to the value. + Parameters ---------- data : array-like, Series, or DataFrame @@ -65,11 +69,12 @@ def get_dummies( Returns ------- DataFrame - Dummy-coded data. + Dummy-coded data. If `data` contains other columns than the + dummy-coded one(s), these will be prepended, unaltered, to the result. See Also -------- - Series.str.get_dummies : Convert Series to dummy codes. + Series.str.get_dummies : Convert Series of strings to dummy codes. :func:`~pandas.from_dummies` : Convert dummy codes to categorical ``DataFrame``. Notes