From 54919a47b65c0eebf8b0bd5ff65fb7629b04ec93 Mon Sep 17 00:00:00 2001 From: Jeff Reback Date: Sun, 6 Mar 2016 16:01:30 -0500 Subject: [PATCH] DOC: fix doc build warnings --- doc/source/basics.rst | 3 +- doc/source/enhancingperf.rst | 1 + doc/source/indexing.rst | 1 + doc/source/options.rst | 3 +- doc/source/r_interface.rst | 2 + doc/source/text.rst | 103 ++++++++++++++++---------------- doc/source/whatsnew/v0.10.0.txt | 1 + doc/source/whatsnew/v0.15.0.txt | 2 +- doc/source/whatsnew/v0.15.1.txt | 11 ++-- doc/source/whatsnew/v0.17.0.txt | 1 + doc/source/whatsnew/v0.18.0.txt | 35 ++++++++--- 11 files changed, 94 insertions(+), 69 deletions(-) diff --git a/doc/source/basics.rst b/doc/source/basics.rst index d0469078aa3e9..1e30921e7248f 100644 --- a/doc/source/basics.rst +++ b/doc/source/basics.rst @@ -370,6 +370,7 @@ be broadcast: or it can return False if broadcasting can not be done: .. ipython:: python + :okwarning: np.array([1, 2, 3]) == np.array([1, 2]) @@ -1757,7 +1758,7 @@ but occasionally has non-dates intermixed and you want to represent as missing. 'foo', 1.0, 1, pd.Timestamp('20010104'), '20010105'], dtype='O') s - s.convert_objects(convert_dates='coerce') + pd.to_datetime(s, errors='coerce') In addition, :meth:`~DataFrame.convert_objects` will attempt the *soft* conversion of any *object* dtypes, meaning that if all the objects in a Series are of the same type, the Series will have that dtype. diff --git a/doc/source/enhancingperf.rst b/doc/source/enhancingperf.rst index 9503675af8681..7451beed7025c 100644 --- a/doc/source/enhancingperf.rst +++ b/doc/source/enhancingperf.rst @@ -98,6 +98,7 @@ First we're going to need to import the cython magic function to ipython (for cython versions >=0.21 you can use ``%load_ext Cython``): .. ipython:: python + :okwarning: %load_ext cythonmagic diff --git a/doc/source/indexing.rst b/doc/source/indexing.rst index 6fa58bf620005..98bc50bae9260 100644 --- a/doc/source/indexing.rst +++ b/doc/source/indexing.rst @@ -1625,6 +1625,7 @@ This is the correct access method This *can* work at times, but is not guaranteed, and so should be avoided .. ipython:: python + :okwarning: dfc = dfc.copy() dfc['A'][0] = 111 diff --git a/doc/source/options.rst b/doc/source/options.rst index be1543f20a461..b02765f469d38 100644 --- a/doc/source/options.rst +++ b/doc/source/options.rst @@ -107,6 +107,7 @@ All options also have a default value, and you can use ``reset_option`` to do ju It's also possible to reset multiple options at once (using a regex): .. ipython:: python + :okwarning: pd.reset_option("^display") @@ -499,5 +500,3 @@ Enabling ``display.unicode.ambiguous_as_wide`` lets pandas to figure these chara pd.set_option('display.unicode.east_asian_width', False) pd.set_option('display.unicode.ambiguous_as_wide', False) - - diff --git a/doc/source/r_interface.rst b/doc/source/r_interface.rst index 74cdc5a526585..71d3bbed223e5 100644 --- a/doc/source/r_interface.rst +++ b/doc/source/r_interface.rst @@ -136,6 +136,7 @@ DataFrames into the equivalent R object (that is, **data.frame**): .. ipython:: python + import pandas.rpy.common as com df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6], 'C':[7,8,9]}, index=["one", "two", "three"]) r_dataframe = com.convert_to_r_dataframe(df) @@ -154,6 +155,7 @@ R matrices bear no information on the data type): .. ipython:: python + import pandas.rpy.common as com r_matrix = com.convert_to_r_matrix(df) print(type(r_matrix)) diff --git a/doc/source/text.rst b/doc/source/text.rst index 42ecfef35e543..655df5c5e566c 100644 --- a/doc/source/text.rst +++ b/doc/source/text.rst @@ -9,7 +9,7 @@ randn = np.random.randn np.set_printoptions(precision=4, suppress=True) from pandas.compat import lrange - options.display.max_rows=15 + pd.options.display.max_rows=15 ====================== Working with Text Data @@ -375,53 +375,54 @@ Method Summary .. csv-table:: :header: "Method", "Description" :widths: 20, 80 - - :meth:`~Series.str.cat`,Concatenate strings - :meth:`~Series.str.split`,Split strings on delimiter - :meth:`~Series.str.rsplit`,Split strings on delimiter working from the end of the string - :meth:`~Series.str.get`,Index into each element (retrieve i-th element) - :meth:`~Series.str.join`,Join strings in each element of the Series with passed separator - :meth:`~Series.str.get_dummies`,Split strings on delimiter, returning DataFrame of dummy variables - :meth:`~Series.str.contains`,Return boolean array if each string contains pattern/regex - :meth:`~Series.str.replace`,Replace occurrences of pattern/regex with some other string - :meth:`~Series.str.repeat`,Duplicate values (``s.str.repeat(3)`` equivalent to ``x * 3``) - :meth:`~Series.str.pad`,"Add whitespace to left, right, or both sides of strings" - :meth:`~Series.str.center`,Equivalent to ``str.center`` - :meth:`~Series.str.ljust`,Equivalent to ``str.ljust`` - :meth:`~Series.str.rjust`,Equivalent to ``str.rjust`` - :meth:`~Series.str.zfill`,Equivalent to ``str.zfill`` - :meth:`~Series.str.wrap`,Split long strings into lines with length less than a given width - :meth:`~Series.str.slice`,Slice each string in the Series - :meth:`~Series.str.slice_replace`,Replace slice in each string with passed value - :meth:`~Series.str.count`,Count occurrences of pattern - :meth:`~Series.str.startswith`,Equivalent to ``str.startswith(pat)`` for each element - :meth:`~Series.str.endswith`,Equivalent to ``str.endswith(pat)`` for each element - :meth:`~Series.str.findall`,Compute list of all occurrences of pattern/regex for each string - :meth:`~Series.str.match`,"Call ``re.match`` on each element, returning matched groups as list" - :meth:`~Series.str.extract`,"Call ``re.search`` on each element, returning DataFrame with one row for each element and one column for each regex capture group" - :meth:`~Series.str.extractall`,"Call ``re.findall`` on each element, returning DataFrame with one row for each match and one column for each regex capture group" - :meth:`~Series.str.len`,Compute string lengths - :meth:`~Series.str.strip`,Equivalent to ``str.strip`` - :meth:`~Series.str.rstrip`,Equivalent to ``str.rstrip`` - :meth:`~Series.str.lstrip`,Equivalent to ``str.lstrip`` - :meth:`~Series.str.partition`,Equivalent to ``str.partition`` - :meth:`~Series.str.rpartition`,Equivalent to ``str.rpartition`` - :meth:`~Series.str.lower`,Equivalent to ``str.lower`` - :meth:`~Series.str.upper`,Equivalent to ``str.upper`` - :meth:`~Series.str.find`,Equivalent to ``str.find`` - :meth:`~Series.str.rfind`,Equivalent to ``str.rfind`` - :meth:`~Series.str.index`,Equivalent to ``str.index`` - :meth:`~Series.str.rindex`,Equivalent to ``str.rindex`` - :meth:`~Series.str.capitalize`,Equivalent to ``str.capitalize`` - :meth:`~Series.str.swapcase`,Equivalent to ``str.swapcase`` - :meth:`~Series.str.normalize`,Return Unicode normal form. Equivalent to ``unicodedata.normalize`` - :meth:`~Series.str.translate`,Equivalent to ``str.translate`` - :meth:`~Series.str.isalnum`,Equivalent to ``str.isalnum`` - :meth:`~Series.str.isalpha`,Equivalent to ``str.isalpha`` - :meth:`~Series.str.isdigit`,Equivalent to ``str.isdigit`` - :meth:`~Series.str.isspace`,Equivalent to ``str.isspace`` - :meth:`~Series.str.islower`,Equivalent to ``str.islower`` - :meth:`~Series.str.isupper`,Equivalent to ``str.isupper`` - :meth:`~Series.str.istitle`,Equivalent to ``str.istitle`` - :meth:`~Series.str.isnumeric`,Equivalent to ``str.isnumeric`` - :meth:`~Series.str.isdecimal`,Equivalent to ``str.isdecimal`` + :delim: ; + + :meth:`~Series.str.cat`;Concatenate strings + :meth:`~Series.str.split`;Split strings on delimiter + :meth:`~Series.str.rsplit`;Split strings on delimiter working from the end of the string + :meth:`~Series.str.get`;Index into each element (retrieve i-th element) + :meth:`~Series.str.join`;Join strings in each element of the Series with passed separator + :meth:`~Series.str.get_dummies`;Split strings on the delimiter returning DataFrame of dummy variables + :meth:`~Series.str.contains`;Return boolean array if each string contains pattern/regex + :meth:`~Series.str.replace`;Replace occurrences of pattern/regex with some other string + :meth:`~Series.str.repeat`;Duplicate values (``s.str.repeat(3)`` equivalent to ``x * 3``) + :meth:`~Series.str.pad`;"Add whitespace to left, right, or both sides of strings" + :meth:`~Series.str.center`;Equivalent to ``str.center`` + :meth:`~Series.str.ljust`;Equivalent to ``str.ljust`` + :meth:`~Series.str.rjust`;Equivalent to ``str.rjust`` + :meth:`~Series.str.zfill`;Equivalent to ``str.zfill`` + :meth:`~Series.str.wrap`;Split long strings into lines with length less than a given width + :meth:`~Series.str.slice`;Slice each string in the Series + :meth:`~Series.str.slice_replace`;Replace slice in each string with passed value + :meth:`~Series.str.count`;Count occurrences of pattern + :meth:`~Series.str.startswith`;Equivalent to ``str.startswith(pat)`` for each element + :meth:`~Series.str.endswith`;Equivalent to ``str.endswith(pat)`` for each element + :meth:`~Series.str.findall`;Compute list of all occurrences of pattern/regex for each string + :meth:`~Series.str.match`;"Call ``re.match`` on each element, returning matched groups as list" + :meth:`~Series.str.extract`;"Call ``re.search`` on each element, returning DataFrame with one row for each element and one column for each regex capture group" + :meth:`~Series.str.extractall`;"Call ``re.findall`` on each element, returning DataFrame with one row for each match and one column for each regex capture group" + :meth:`~Series.str.len`;Compute string lengths + :meth:`~Series.str.strip`;Equivalent to ``str.strip`` + :meth:`~Series.str.rstrip`;Equivalent to ``str.rstrip`` + :meth:`~Series.str.lstrip`;Equivalent to ``str.lstrip`` + :meth:`~Series.str.partition`;Equivalent to ``str.partition`` + :meth:`~Series.str.rpartition`;Equivalent to ``str.rpartition`` + :meth:`~Series.str.lower`;Equivalent to ``str.lower`` + :meth:`~Series.str.upper`;Equivalent to ``str.upper`` + :meth:`~Series.str.find`;Equivalent to ``str.find`` + :meth:`~Series.str.rfind`;Equivalent to ``str.rfind`` + :meth:`~Series.str.index`;Equivalent to ``str.index`` + :meth:`~Series.str.rindex`;Equivalent to ``str.rindex`` + :meth:`~Series.str.capitalize`;Equivalent to ``str.capitalize`` + :meth:`~Series.str.swapcase`;Equivalent to ``str.swapcase`` + :meth:`~Series.str.normalize`;Return Unicode normal form. Equivalent to ``unicodedata.normalize`` + :meth:`~Series.str.translate`;Equivalent to ``str.translate`` + :meth:`~Series.str.isalnum`;Equivalent to ``str.isalnum`` + :meth:`~Series.str.isalpha`;Equivalent to ``str.isalpha`` + :meth:`~Series.str.isdigit`;Equivalent to ``str.isdigit`` + :meth:`~Series.str.isspace`;Equivalent to ``str.isspace`` + :meth:`~Series.str.islower`;Equivalent to ``str.islower`` + :meth:`~Series.str.isupper`;Equivalent to ``str.isupper`` + :meth:`~Series.str.istitle`;Equivalent to ``str.istitle`` + :meth:`~Series.str.isnumeric`;Equivalent to ``str.isnumeric`` + :meth:`~Series.str.isdecimal`;Equivalent to ``str.isdecimal`` diff --git a/doc/source/whatsnew/v0.10.0.txt b/doc/source/whatsnew/v0.10.0.txt index 48ce09f32b12b..f409be7dd0f41 100644 --- a/doc/source/whatsnew/v0.10.0.txt +++ b/doc/source/whatsnew/v0.10.0.txt @@ -292,6 +292,7 @@ Updated PyTables Support store.select('df') .. ipython:: python + :okwarning: wp = Panel(randn(2, 5, 4), items=['Item1', 'Item2'], major_axis=date_range('1/1/2000', periods=5), diff --git a/doc/source/whatsnew/v0.15.0.txt b/doc/source/whatsnew/v0.15.0.txt index 9651c1efeff4a..3d992206cb426 100644 --- a/doc/source/whatsnew/v0.15.0.txt +++ b/doc/source/whatsnew/v0.15.0.txt @@ -420,7 +420,7 @@ Rolling/Expanding Moments improvements New behavior - .. ipython:: python + .. code-block:: python In [10]: pd.rolling_window(s, window=3, win_type='triang', center=True) Out[10]: diff --git a/doc/source/whatsnew/v0.15.1.txt b/doc/source/whatsnew/v0.15.1.txt index bd878db08a3ed..79efa2b278ae7 100644 --- a/doc/source/whatsnew/v0.15.1.txt +++ b/doc/source/whatsnew/v0.15.1.txt @@ -110,19 +110,18 @@ API changes .. code-block:: python - In [8]: s.loc[3.5:1.5] - KeyError: 3.5 + In [8]: s.loc[3.5:1.5] + KeyError: 3.5 current behavior: .. ipython:: python - s.loc[3.5:1.5] - + s.loc[3.5:1.5] - ``io.data.Options`` has been fixed for a change in the format of the Yahoo Options page (:issue:`8612`), (:issue:`8741`) - .. note:: + .. note:: As a result of a change in Yahoo's option page layout, when an expiry date is given, ``Options`` methods now return data for a single expiry date. Previously, methods returned all @@ -146,6 +145,7 @@ API changes Current behavior: .. ipython:: python + :okwarning: from pandas.io.data import Options aapl = Options('aapl','yahoo') @@ -274,4 +274,3 @@ Bug Fixes - Bug in Setting by indexer to a scalar value with a mixed-dtype `Panel4d` was failing (:issue:`8702`) - Bug where ``DataReader``'s would fail if one of the symbols passed was invalid. Now returns data for valid symbols and np.nan for invalid (:issue:`8494`) - Bug in ``get_quote_yahoo`` that wouldn't allow non-float return values (:issue:`5229`). - diff --git a/doc/source/whatsnew/v0.17.0.txt b/doc/source/whatsnew/v0.17.0.txt index 9f943fa68e639..92eafdac387fa 100644 --- a/doc/source/whatsnew/v0.17.0.txt +++ b/doc/source/whatsnew/v0.17.0.txt @@ -723,6 +723,7 @@ be broadcast: or it can return False if broadcasting can not be done: .. ipython:: python + :okwarning: np.array([1, 2, 3]) == np.array([1, 2]) diff --git a/doc/source/whatsnew/v0.18.0.txt b/doc/source/whatsnew/v0.18.0.txt index 40c61b041babf..bdc20d964a06a 100644 --- a/doc/source/whatsnew/v0.18.0.txt +++ b/doc/source/whatsnew/v0.18.0.txt @@ -192,6 +192,7 @@ In v0.18.0, the ``expand`` argument was added to Currently the default is ``expand=None`` which gives a ``FutureWarning`` and uses ``expand=False``. To avoid this warning, please explicitly specify ``expand``. .. ipython:: python + :okwarning: pd.Series(['a1', 'b2', 'c3']).str.extract('[ab](\d)', expand=None) @@ -608,12 +609,10 @@ Changes to msgpack Forward incompatible changes in ``msgpack`` writing format were made over 0.17.0 and 0.18.0; older versions of pandas cannot read files packed by newer versions (:issue:`12129`, `10527`) -Bug in ``to_msgpack`` and ``read_msgpack`` introduced in 0.17.0 and fixed in 0.18.0, caused files packed in Python 2 unreadable by Python 3 (:issue:`12142`) +Bug in ``to_msgpack`` and ``read_msgpack`` introduced in 0.17.0 and fixed in 0.18.0, caused files packed in Python 2 unreadable by Python 3 (:issue:`12142`). The following table describes the backward and forward compat of msgpacks. .. warning:: - As a result of a number of issues: - +----------------------+------------------------+ | Packed with | Can be unpacked with | +======================+========================+ @@ -621,13 +620,14 @@ Bug in ``to_msgpack`` and ``read_msgpack`` introduced in 0.17.0 and fixed in 0.1 +----------------------+------------------------+ | pre-0.17 / Python 3 | any | +----------------------+------------------------+ - | 0.17 / Python 2 | - 0.17 / Python 2 | + | 0.17 / Python 2 | - ==0.17 / Python 2 | | | - >=0.18 / any Python | +----------------------+------------------------+ | 0.17 / Python 3 | >=0.18 / any Python | +----------------------+------------------------+ | 0.18 | >= 0.18 | - +======================+========================+ + +----------------------+------------------------+ + 0.18.0 is backward-compatible for reading files packed by older versions, except for files packed with 0.17 in Python 2, in which case only they can only be unpacked in Python 2. @@ -780,7 +780,7 @@ Now, you can write ``.resample`` as a 2-stage operation like groupby, which yields a ``Resampler``. .. ipython:: python - + :okwarning: r = df.resample('2s') r @@ -872,9 +872,28 @@ in an inplace change to the ``DataFrame``. (:issue:`9297`) .. ipython:: python df = pd.DataFrame({'a': np.linspace(0, 10, 5), 'b': range(5)}) - df.eval('c = a + b') df +.. ipython:: python + :suppress: + + df.eval('c = a + b', inplace=True) + +.. code-block:: python + + In [12]: df.eval('c = a + b') + FutureWarning: eval expressions containing an assignment currentlydefault to operating inplace. + This will change in a future version of pandas, use inplace=True to avoid this warning. + + In [13]: df + Out[13]: + a b c + 0 0.0 0 0.0 + 1 2.5 1 3.5 + 2 5.0 2 7.0 + 3 7.5 3 10.5 + 4 10.0 4 14.0 + In version 0.18.0, a new ``inplace`` keyword was added to choose whether the assignment should be done inplace or return a copy. @@ -941,7 +960,7 @@ Other API Changes - ``DataFrame.to_latex()`` now supports non-ascii encodings (eg utf-8) in Python 2 with the parameter ``encoding`` (:issue:`7061`) - ``pandas.merge()`` and ``DataFrame.merge()`` will show a specific error message when trying to merge with an object that is not of type ``DataFrame`` or a subclass (:issue:`12081`) - ``DataFrame.unstack`` and ``Series.unstack`` now take ``fill_value`` keyword to allow direct replacement of missing values when an unstack results in missing values in the resulting ``DataFrame``. As an added benefit, specifying ``fill_value`` will preserve the data type of the original stacked data. (:issue:`9746`) -- As part of the new API for :ref:`window functions ` and :ref:`resampling `, aggregation functions have been clarified, raising more informative error messages on invalid aggregations. (:issue:`9052`). A full set of examples are presented in :ref:`groupby `. +- As part of the new API for :ref:`window functions ` and :ref:`resampling `, aggregation functions have been clarified, raising more informative error messages on invalid aggregations. (:issue:`9052`). A full set of examples are presented in :ref:`groupby `. - Statistical functions for ``NDFrame`` objects will now raise if non-numpy-compatible arguments are passed in for ``**kwargs`` (:issue:`12301`) - ``.to_latex`` and ``.to_html`` gain a ``decimal`` parameter like ``.to_csv``; the default is ``'.'`` (:issue:`12031`) - More helpful error message when constructing a ``DataFrame`` with empty data but with indices (:issue:`8020`)