Skip to content

Commit ea0a13c

Browse files
jankatinsjreback
authored andcommitted
Categorical: Thanks for Jan Schulz for much of the work on Categoricals
Doc: Add Release notes for #7217 DOC: update v0.15.0 notes Categorical: .codes should be immutable ERR: codes modification raises ValueError always Categorical: use Categorical.from_codes() in a few places Categorical: Fix assigning a Categorical to an existing string column CLN: CategoricalDtype repr now yields category DISPLAY: show dtype when displaying Categorical series (for consistency) BUG: fix groupby with multiple non-compressed categoricals Categorical: minor doc cleanups ENH: add a metaclass to CategoricalDtype to provide issubclass support (for select_dtypes) TST: io/pytables.py tests now raise NotImplementedError for dtype==category DOC: document the new category dtype in select_dtypes
1 parent 0f62d3f commit ea0a13c

22 files changed

+660
-356
lines changed

doc/source/api.rst

+11-5
Original file line numberDiff line numberDiff line change
@@ -485,18 +485,26 @@ and has the following usable methods and properties (all available as
485485
:toctree: generated/
486486

487487
Categorical
488+
Categorical.from_codes
488489
Categorical.levels
489490
Categorical.ordered
490491
Categorical.reorder_levels
491492
Categorical.remove_unused_levels
492493
Categorical.min
493494
Categorical.max
494495
Categorical.mode
496+
Categorical.describe
497+
498+
``np.asarray(categorical)`` works by implementing the array interface. Be aware, that this converts
499+
the Categorical back to a numpy array, so levels and order information is not preserved!
500+
501+
.. autosummary::
502+
:toctree: generated/
503+
504+
Categorical.__array__
495505

496506
To create compatibility with `pandas.Series` and `numpy` arrays, the following (non-API) methods
497-
are also introduced. Apart from these methods, ``np.asarray(categorical)`` works by implementing the
498-
array interface (`Categorical.__array__()`). Be aware, that this converts the
499-
Categorical back to a numpy array, so levels and order information is not preserved!
507+
are also introduced.
500508

501509
.. autosummary::
502510
:toctree: generated/
@@ -507,13 +515,11 @@ Categorical back to a numpy array, so levels and order information is not preser
507515
Categorical.dtype
508516
Categorical.ndim
509517
Categorical.sort
510-
Categorical.describe
511518
Categorical.equals
512519
Categorical.unique
513520
Categorical.order
514521
Categorical.argsort
515522
Categorical.fillna
516-
Categorical.__array__
517523

518524

519525
Plotting

doc/source/basics.rst

+7-1
Original file line numberDiff line numberDiff line change
@@ -1574,7 +1574,8 @@ dtypes:
15741574
'float64': np.arange(4.0, 7.0),
15751575
'bool1': [True, False, True],
15761576
'bool2': [False, True, False],
1577-
'dates': pd.date_range('now', periods=3).values})
1577+
'dates': pd.date_range('now', periods=3).values}),
1578+
'category': pd.Categorical(list("ABC))
15781579
df['tdeltas'] = df.dates.diff()
15791580
df['uint64'] = np.arange(3, 6).astype('u8')
15801581
df['other_dates'] = pd.date_range('20130101', periods=3).values
@@ -1630,6 +1631,11 @@ All numpy dtypes are subclasses of ``numpy.generic``:
16301631
16311632
subdtypes(np.generic)
16321633
1634+
.. note::
1635+
1636+
Pandas also defines an additional ``category`` dtype, which is not integrated into the normal
1637+
numpy hierarchy and wont show up with the above function.
1638+
16331639
.. note::
16341640
16351641
The ``include`` and ``exclude`` parameters must be non-string sequences.

0 commit comments

Comments
 (0)