Skip to content

Commit 9099175

Browse files
committed
okwarning option
1 parent 899ad1b commit 9099175

File tree

8 files changed

+15
-1
lines changed

8 files changed

+15
-1
lines changed

doc/source/user_guide/10min.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,7 @@ Sorting is per order in the categories, not lexical order.
705705
Grouping by a categorical column also shows empty categories.
706706

707707
.. ipython:: python
708+
:okwarning:
708709
709710
df.groupby("grade").size()
710711

doc/source/user_guide/advanced.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,7 @@ order is ``cab``).
808808
Groupby operations on the index will preserve the index nature as well.
809809

810810
.. ipython:: python
811+
:okwarning:
811812
812813
df2.groupby(level=0).sum()
813814
df2.groupby(level=0).sum().index

doc/source/user_guide/categorical.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,16 +615,20 @@ Apart from :meth:`Series.min`, :meth:`Series.max` and :meth:`Series.mode`, the
615615
following 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

677683
If 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

doc/source/user_guide/cookbook.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,7 @@ The :ref:`Plotting <visualization>` docs.
10351035
<https://stackoverflow.com/questions/23232989/boxplot-stratified-by-column-in-python-pandas>`__
10361036

10371037
.. ipython:: python
1038+
:okwarning:
10381039
10391040
df = pd.DataFrame(
10401041
{

doc/source/user_guide/groupby.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,6 +1255,7 @@ Categorical variables represented as instance of pandas's ``Categorical`` class
12551255
can be used as group keys. If so, the order of the levels will be preserved:
12561256

12571257
.. ipython:: python
1258+
:okwarning:
12581259
12591260
data = pd.Series(np.random.randn(100))
12601261

doc/source/whatsnew/v0.19.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,7 @@ An analogous change has been made to ``MultiIndex.from_product``.
11311131
As a consequence, ``groupby`` and ``set_index`` also preserve categorical dtypes in indexes
11321132

11331133
.. ipython:: python
1134+
:okwarning:
11341135
11351136
df = pd.DataFrame({"A": [0, 1], "B": [10, 11], "C": cat})
11361137
df_grouped = df.groupby(by=["A", "C"]).first()

doc/source/whatsnew/v0.20.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ In previous versions, ``.groupby(..., sort=False)`` would fail with a ``ValueErr
291291
**New behavior**:
292292

293293
.. ipython:: python
294+
:okwarning:
294295
295296
df[df.chromosomes != '1'].groupby('chromosomes', sort=False).sum()
296297

doc/source/whatsnew/v0.22.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ instead of ``NaN``.
118118
*pandas 0.22*
119119

120120
.. ipython:: python
121+
:okwarning:
121122
122123
grouper = pd.Categorical(["a", "a"], categories=["a", "b"])
123124
pd.Series([1, 2]).groupby(grouper).sum()

0 commit comments

Comments
 (0)