From 4d3d477200b645ed4c676a74282ca05f3294766a Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Sat, 5 Sep 2015 14:14:54 +0200 Subject: [PATCH] DOC: several doc errors - fix NaNs in categories - add okwarnings - add okexcept for Period freq mismatch --- doc/source/categorical.rst | 11 +++++------ doc/source/remote_data.rst | 1 + doc/source/timeseries.rst | 7 +------ doc/source/visualization.rst | 1 + 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/doc/source/categorical.rst b/doc/source/categorical.rst index 534ab0e343398..ddd4fb81ed1f1 100644 --- a/doc/source/categorical.rst +++ b/doc/source/categorical.rst @@ -149,8 +149,8 @@ Using ``.describe()`` on categorical data will produce similar output to a `Seri .. ipython:: python - cat = pd.Categorical(["a","c","c",np.nan], categories=["b","a","c",np.nan] ) - df = pd.DataFrame({"cat":cat, "s":["a","c","c",np.nan]}) + cat = pd.Categorical(["a", "c", "c", np.nan], categories=["b", "a", "c"]) + df = pd.DataFrame({"cat":cat, "s":["a", "c", "c", np.nan]}) df.describe() df["cat"].describe() @@ -642,10 +642,10 @@ a code of ``-1``. .. ipython:: python - s = pd.Series(["a","b",np.nan,"a"], dtype="category") + s = pd.Series(["a", "b", np.nan, "a"], dtype="category") # only two categories s - s.codes + s.cat.codes Methods for working with missing data, e.g. :meth:`~Series.isnull`, :meth:`~Series.fillna`, @@ -653,8 +653,7 @@ Methods for working with missing data, e.g. :meth:`~Series.isnull`, :meth:`~Seri .. ipython:: python - c = pd.Series(["a","b",np.nan], dtype="category") - s = pd.Series(c) + s = pd.Series(["a", "b", np.nan], dtype="category") s pd.isnull(s) s.fillna("a") diff --git a/doc/source/remote_data.rst b/doc/source/remote_data.rst index 1992288fd4d00..d1a2ba59d7fdf 100644 --- a/doc/source/remote_data.rst +++ b/doc/source/remote_data.rst @@ -62,6 +62,7 @@ Yahoo! Finance -------------- .. ipython:: python + :okwarning: import pandas.io.data as web import datetime diff --git a/doc/source/timeseries.rst b/doc/source/timeseries.rst index 29b955a55fcc9..9795c082ddb98 100644 --- a/doc/source/timeseries.rst +++ b/doc/source/timeseries.rst @@ -1278,17 +1278,12 @@ frequency. Arithmetic is not allowed between ``Period`` with different ``freq`` .. ipython:: python p = Period('2012', freq='A-DEC') - p + 1 - p - 3 - p = Period('2012-01', freq='2M') - p + 2 - p - 1 - + @okexcept p == Period('2012-01', freq='3M') diff --git a/doc/source/visualization.rst b/doc/source/visualization.rst index 4378d182b3128..2eaf143a3e0b8 100644 --- a/doc/source/visualization.rst +++ b/doc/source/visualization.rst @@ -387,6 +387,7 @@ The existing interface ``DataFrame.boxplot`` to plot boxplot still can be used. np.random.seed(123456) .. ipython:: python + :okwarning: df = pd.DataFrame(np.random.rand(10,5)) plt.figure();