@@ -615,16 +615,20 @@ Apart from :meth:`Series.min`, :meth:`Series.max` and :meth:`Series.mode`, the
615615following operations are possible with categorical data:
616616
617617``Series `` methods like :meth: `Series.value_counts ` will use all categories,
618- even if some categories are not present in the data:
618+ even if some categories are not present in the data, though this default is
619+ deprecated and will be changed in a future release. It is recommended to use
620+ the `observed ` keyword explicitly:
619621
620622.. ipython :: python
623+ :okwarning:
621624
622625 s = pd.Series(pd.Categorical([" a" , " b" , " c" , " c" ], categories = [" c" , " a" , " b" , " d" ]))
623626 s.value_counts()
624627
625628 ``DataFrame `` methods like :meth: `DataFrame.sum ` also show "unused" categories.
626629
627630.. ipython :: python
631+ :okwarning:
628632
629633 columns = pd.Categorical(
630634 [" One" , " One" , " Two" ], categories = [" One" , " Two" , " Three" ], ordered = True
@@ -638,6 +642,7 @@ even if some categories are not present in the data:
638642 Groupby will also show "unused" categories:
639643
640644.. ipython :: python
645+ :okwarning:
641646
642647 cats = pd.Categorical(
643648 [" a" , " b" , " b" , " b" , " c" , " c" , " c" ], categories = [" a" , " b" , " c" , " d" ]
@@ -659,6 +664,7 @@ Groupby will also show "unused" categories:
659664 Pivot tables:
660665
661666.. ipython :: python
667+ :okwarning:
662668
663669 raw_cat = pd.Categorical([" a" , " a" , " b" , " b" ], categories = [" a" , " b" , " c" ])
664670 df = pd.DataFrame({" A" : raw_cat, " B" : [" c" , " d" , " c" , " d" ], " values" : [1 , 2 , 3 , 4 ]})
@@ -676,6 +682,7 @@ Getting
676682
677683If the slicing operation returns either a ``DataFrame `` or a column of type
678684``Series ``, the ``category `` dtype is preserved.
685+ :okwarning:
679686
680687.. ipython :: python
681688
0 commit comments