Skip to content

Commit 9de430e

Browse files
Merge pull request #10999 from jorisvandenbossche/doc-cat-nan
DOC: fix NaNs in categories
2 parents 958f87d + 4d3d477 commit 9de430e

File tree

4 files changed

+8
-12
lines changed

4 files changed

+8
-12
lines changed

doc/source/categorical.rst

+5-6
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ Using ``.describe()`` on categorical data will produce similar output to a `Seri
149149

150150
.. ipython:: python
151151
152-
cat = pd.Categorical(["a","c","c",np.nan], categories=["b","a","c",np.nan] )
153-
df = pd.DataFrame({"cat":cat, "s":["a","c","c",np.nan]})
152+
cat = pd.Categorical(["a", "c", "c", np.nan], categories=["b", "a", "c"])
153+
df = pd.DataFrame({"cat":cat, "s":["a", "c", "c", np.nan]})
154154
df.describe()
155155
df["cat"].describe()
156156
@@ -642,19 +642,18 @@ a code of ``-1``.
642642

643643
.. ipython:: python
644644
645-
s = pd.Series(["a","b",np.nan,"a"], dtype="category")
645+
s = pd.Series(["a", "b", np.nan, "a"], dtype="category")
646646
# only two categories
647647
s
648-
s.codes
648+
s.cat.codes
649649
650650
651651
Methods for working with missing data, e.g. :meth:`~Series.isnull`, :meth:`~Series.fillna`,
652652
:meth:`~Series.dropna`, all work normally:
653653

654654
.. ipython:: python
655655
656-
c = pd.Series(["a","b",np.nan], dtype="category")
657-
s = pd.Series(c)
656+
s = pd.Series(["a", "b", np.nan], dtype="category")
658657
s
659658
pd.isnull(s)
660659
s.fillna("a")

doc/source/remote_data.rst

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Yahoo! Finance
6262
--------------
6363

6464
.. ipython:: python
65+
:okwarning:
6566
6667
import pandas.io.data as web
6768
import datetime

doc/source/timeseries.rst

+1-6
Original file line numberDiff line numberDiff line change
@@ -1278,17 +1278,12 @@ frequency. Arithmetic is not allowed between ``Period`` with different ``freq``
12781278
.. ipython:: python
12791279
12801280
p = Period('2012', freq='A-DEC')
1281-
12821281
p + 1
1283-
12841282
p - 3
1285-
12861283
p = Period('2012-01', freq='2M')
1287-
12881284
p + 2
1289-
12901285
p - 1
1291-
1286+
@okexcept
12921287
p == Period('2012-01', freq='3M')
12931288
12941289

doc/source/visualization.rst

+1
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ The existing interface ``DataFrame.boxplot`` to plot boxplot still can be used.
387387
np.random.seed(123456)
388388
389389
.. ipython:: python
390+
:okwarning:
390391
391392
df = pd.DataFrame(np.random.rand(10,5))
392393
plt.figure();

0 commit comments

Comments
 (0)