@@ -6352,20 +6352,22 @@ def describe(self, percentiles=None, include=None, exclude=None):
6352
6352
- A list-like of dtypes : Limits the results to the
6353
6353
provided data types.
6354
6354
To limit the result to numeric types submit
6355
- ``numpy.number``. To limit it instead to categorical
6356
- objects submit the ``numpy.object`` data type. Strings
6355
+ ``numpy.number``. To limit it instead to object columns submit
6356
+ the ``numpy.object`` data type. Strings
6357
6357
can also be used in the style of
6358
- ``select_dtypes`` (e.g. ``df.describe(include=['O'])``)
6358
+ ``select_dtypes`` (e.g. ``df.describe(include=['O'])``). To
6359
+ select pandas categorical columns, use ``'category'``
6359
6360
- None (default) : The result will include all numeric columns.
6360
6361
exclude : list-like of dtypes or None (default), optional,
6361
6362
A black list of data types to omit from the result. Ignored
6362
6363
for ``Series``. Here are the options:
6363
6364
6364
6365
- A list-like of dtypes : Excludes the provided data types
6365
- from the result. To select numeric types submit
6366
- ``numpy.number``. To select categorical objects submit the data
6366
+ from the result. To exclude numeric types submit
6367
+ ``numpy.number``. To exclude object columns submit the data
6367
6368
type ``numpy.object``. Strings can also be used in the style of
6368
- ``select_dtypes`` (e.g. ``df.describe(include=['O'])``)
6369
+ ``select_dtypes`` (e.g. ``df.describe(include=['O'])``). To
6370
+ exclude pandas categorical columns, use ``'category'``
6369
6371
- None (default) : The result will exclude nothing.
6370
6372
6371
6373
Returns
@@ -6390,9 +6392,11 @@ def describe(self, percentiles=None, include=None, exclude=None):
6390
6392
among those with the highest count.
6391
6393
6392
6394
For mixed data types provided via a ``DataFrame``, the default is to
6393
- return only an analysis of numeric columns. If ``include='all'``
6394
- is provided as an option, the result will include a union of
6395
- attributes of each type.
6395
+ return only an analysis of numeric columns. If the dataframe consists
6396
+ only of object and categorical data without any numeric columns, the
6397
+ default is to return an analysis of both the object and categorical
6398
+ columns. If ``include='all'`` is provided as an option, the result
6399
+ will include a union of attributes of each type.
6396
6400
6397
6401
The `include` and `exclude` parameters can be used to limit
6398
6402
which columns in a ``DataFrame`` are analyzed for the output.
@@ -6442,8 +6446,10 @@ def describe(self, percentiles=None, include=None, exclude=None):
6442
6446
Describing a ``DataFrame``. By default only numeric fields
6443
6447
are returned.
6444
6448
6445
- >>> df = pd.DataFrame([[1, 'a'], [2, 'b'], [3, 'c']],
6446
- ... columns=['numeric', 'object'])
6449
+ >>> df = pd.DataFrame({ 'object': ['a', 'b', 'c'],
6450
+ ... 'numeric': [1, 2, 3],
6451
+ ... 'categorical': pd.Categorical(['d','e','f'])
6452
+ ... })
6447
6453
>>> df.describe()
6448
6454
numeric
6449
6455
count 3.0
@@ -6457,19 +6463,19 @@ def describe(self, percentiles=None, include=None, exclude=None):
6457
6463
6458
6464
Describing all columns of a ``DataFrame`` regardless of data type.
6459
6465
6460
- >>> df.describe(include='all')
6461
- numeric object
6462
- count 3.0 3
6463
- unique NaN 3
6464
- top NaN b
6465
- freq NaN 1
6466
- mean 2.0 NaN
6467
- std 1.0 NaN
6468
- min 1.0 NaN
6469
- 25% 1.5 NaN
6470
- 50% 2.0 NaN
6471
- 75% 2.5 NaN
6472
- max 3.0 NaN
6466
+ >>> df.describe(include='all')
6467
+ categorical numeric object
6468
+ count 3 3.0 3
6469
+ unique 3 NaN 3
6470
+ top f NaN c
6471
+ freq 1 NaN 1
6472
+ mean NaN 2.0 NaN
6473
+ std NaN 1.0 NaN
6474
+ min NaN 1.0 NaN
6475
+ 25% NaN 1.5 NaN
6476
+ 50% NaN 2.0 NaN
6477
+ 75% NaN 2.5 NaN
6478
+ max NaN 3.0 NaN
6473
6479
6474
6480
Describing a column from a ``DataFrame`` by accessing it as
6475
6481
an attribute.
@@ -6483,7 +6489,6 @@ def describe(self, percentiles=None, include=None, exclude=None):
6483
6489
50% 2.0
6484
6490
75% 2.5
6485
6491
max 3.0
6486
- Name: numeric, dtype: float64
6487
6492
6488
6493
Including only numeric columns in a ``DataFrame`` description.
6489
6494
@@ -6504,31 +6509,43 @@ def describe(self, percentiles=None, include=None, exclude=None):
6504
6509
object
6505
6510
count 3
6506
6511
unique 3
6507
- top b
6512
+ top c
6508
6513
freq 1
6509
6514
6515
+ Including only categorical columns from a ``DataFrame`` description.
6516
+
6517
+ >>> df.describe(include=['category'])
6518
+ categorical
6519
+ count 3
6520
+ unique 3
6521
+ top f
6522
+ freq 1
6523
+
6510
6524
Excluding numeric columns from a ``DataFrame`` description.
6511
6525
6512
6526
>>> df.describe(exclude=[np.number])
6513
- object
6514
- count 3
6515
- unique 3
6516
- top b
6517
- freq 1
6527
+ categorical object
6528
+ count 3 3
6529
+ unique 3 3
6530
+ top f c
6531
+ freq 1 1
6518
6532
6519
6533
Excluding object columns from a ``DataFrame`` description.
6520
6534
6521
6535
>>> df.describe(exclude=[np.object])
6522
- numeric
6523
- count 3.0
6524
- mean 2.0
6525
- std 1.0
6526
- min 1.0
6527
- 25% 1.5
6528
- 50% 2.0
6529
- 75% 2.5
6530
- max 3.0
6531
-
6536
+ categorical numeric
6537
+ count 3 3.0
6538
+ unique 3 NaN
6539
+ top f NaN
6540
+ freq 1 NaN
6541
+ mean NaN 2.0
6542
+ std NaN 1.0
6543
+ min NaN 1.0
6544
+ 25% NaN 1.5
6545
+ 50% NaN 2.0
6546
+ 75% NaN 2.5
6547
+ max NaN 3.0
6548
+
6532
6549
See Also
6533
6550
--------
6534
6551
DataFrame.count
0 commit comments