From 4c73c420ee3c87c1f8fa986258a6d7224217d246 Mon Sep 17 00:00:00 2001 From: sfoo Date: Thu, 25 May 2017 21:50:16 -0700 Subject: [PATCH 1/6] DOC: Added sphinx deprecated directive XR#6581 --- doc/source/io.rst | 17 ++++++--- doc/sphinxext/numpydoc/README.rst | 4 +- pandas/_libs/tslib.pyx | 3 +- pandas/core/categorical.py | 21 ++++++----- pandas/core/common.py | 7 ++-- pandas/core/frame.py | 3 +- pandas/core/generic.py | 21 +++++++---- pandas/core/indexes/base.py | 3 +- pandas/core/indexes/datetimes.py | 10 +++-- pandas/core/indexes/period.py | 3 +- pandas/core/panel4d.py | 9 +++-- pandas/core/panelnd.py | 9 +++-- pandas/core/series.py | 8 ++-- pandas/core/sparse/array.py | 5 ++- pandas/core/strings.py | 5 ++- pandas/core/window.py | 61 ++++++++++++++++++------------- pandas/io/excel.py | 7 ++-- pandas/io/parsers.py | 19 ++++++---- pandas/io/sql.py | 9 +++-- pandas/io/stata.py | 8 ++-- 20 files changed, 142 insertions(+), 90 deletions(-) diff --git a/doc/source/io.rst b/doc/source/io.rst index bca23dd18a0e3..73ce45dee2cfa 100644 --- a/doc/source/io.rst +++ b/doc/source/io.rst @@ -137,8 +137,9 @@ usecols : array-like or callable, default ``None`` Using this parameter results in much faster parsing time and lower memory usage. as_recarray : boolean, default ``False`` - DEPRECATED: this argument will be removed in a future version. Please call - ``pd.read_csv(...).to_records()`` instead. + .. deprecated:: 0.18.2 + This argument will be removed in a future version. Please call + ``pd.read_csv(...).to_records()`` instead. Return a NumPy recarray instead of a DataFrame after parsing the data. If set to ``True``, this option takes precedence over the ``squeeze`` parameter. @@ -191,7 +192,8 @@ skiprows : list-like or integer, default ``None`` skipfooter : int, default ``0`` Number of lines at bottom of file to skip (unsupported with engine='c'). skip_footer : int, default ``0`` - DEPRECATED: use the ``skipfooter`` parameter instead, as they are identical + .. deprecated:: 0.19.0 + Use the ``skipfooter`` parameter instead, as they are identical nrows : int, default ``None`` Number of rows of file to read. Useful for reading pieces of large files. low_memory : boolean, default ``True`` @@ -202,16 +204,19 @@ low_memory : boolean, default ``True`` use the ``chunksize`` or ``iterator`` parameter to return the data in chunks. (Only valid with C parser) buffer_lines : int, default None - DEPRECATED: this argument will be removed in a future version because its - value is not respected by the parser + .. deprecated:: 0.18.2 + This argument will be removed in a future version because its + value is not respected by the parser compact_ints : boolean, default False + .. deprecated:: 0.18.2 DEPRECATED: this argument will be removed in a future version If ``compact_ints`` is ``True``, then for any column that is of integer dtype, the parser will attempt to cast it as the smallest integer ``dtype`` possible, either signed or unsigned depending on the specification from the ``use_unsigned`` parameter. use_unsigned : boolean, default False - DEPRECATED: this argument will be removed in a future version + .. deprecated:: 0.18.2 + This argument will be removed in a future version If integer columns are being compacted (i.e. ``compact_ints=True``), specify whether the column should be compacted to the smallest signed or unsigned integer dtype. diff --git a/doc/sphinxext/numpydoc/README.rst b/doc/sphinxext/numpydoc/README.rst index 89b9f2fd23e9b..eff87a4473e56 100755 --- a/doc/sphinxext/numpydoc/README.rst +++ b/doc/sphinxext/numpydoc/README.rst @@ -46,6 +46,8 @@ The following options can be set in conf.py: methods and attributes. If a table of contents is made, Sphinx expects each entry to have a separate page. -- numpydoc_edit_link: bool (DEPRECATED -- edit your HTML template instead) +- numpydoc_edit_link: bool + .. deprecated:: + Edit your HTML template instead Whether to insert an edit link after docstrings. diff --git a/pandas/_libs/tslib.pyx b/pandas/_libs/tslib.pyx index c471d46262484..28e7d02819d44 100644 --- a/pandas/_libs/tslib.pyx +++ b/pandas/_libs/tslib.pyx @@ -1148,7 +1148,8 @@ cdef class _Timestamp(datetime): cpdef datetime to_datetime(_Timestamp self): """ - DEPRECATED: use :meth:`to_pydatetime` instead. + .. deprecated:: 0.19.0 + Use :meth:`to_pydatetime` instead. Convert a Timestamp object to a native Python datetime object. """ diff --git a/pandas/core/categorical.py b/pandas/core/categorical.py index 5b663f1d85ee7..96cb4f124c1a9 100644 --- a/pandas/core/categorical.py +++ b/pandas/core/categorical.py @@ -391,8 +391,8 @@ def itemsize(self): def reshape(self, new_shape, *args, **kwargs): """ - DEPRECATED: calling this method will raise an error in a - future release. + .. deprecated:: 0.19.0 + Calling this method will raise an error in a future release. An ndarray-compatible method that returns `self` because `Categorical` instances cannot actually be reshaped. @@ -423,7 +423,8 @@ def base(self): @classmethod def from_array(cls, data, **kwargs): """ - DEPRECATED: Use ``Categorical`` instead. + .. deprecated:: + Use ``Categorical`` instead. Make a Categorical type from a single array-like object. @@ -1442,8 +1443,9 @@ def _values_for_rank(self): def order(self, inplace=False, ascending=True, na_position='last'): """ - DEPRECATED: use :meth:`Categorical.sort_values`. That function - is entirely equivalent to this one. + .. deprecated:: 0.18.1 + Use :meth:`Categorical.sort_values`. That function + is entirely equivalent to this one. See Also -------- @@ -1456,10 +1458,11 @@ def order(self, inplace=False, ascending=True, na_position='last'): def sort(self, inplace=True, ascending=True, na_position='last', **kwargs): """ - DEPRECATED: use :meth:`Categorical.sort_values`. That function - is just like this one, except that a new Categorical is returned - by default, so make sure to pass in 'inplace=True' to get - inplace sorting. + .. deprecated:: 0.18.1 + Use :meth:`Categorical.sort_values`. That function + is just like this one, except that a new Categorical is returned + by default, so make sure to pass in 'inplace=True' to get + inplace sorting. See Also -------- diff --git a/pandas/core/common.py b/pandas/core/common.py index 0dc6a7a1e9c7b..fa34b80cd30e0 100644 --- a/pandas/core/common.py +++ b/pandas/core/common.py @@ -548,7 +548,8 @@ def in_qtconsole(): """ check if we're inside an IPython qtconsole - DEPRECATED: This is no longer needed, or working, in IPython 3 and above. + .. deprecated:: 0.14.1 + This is no longer needed, or working, in IPython 3 and above. """ try: ip = get_ipython() # noqa @@ -566,8 +567,8 @@ def in_ipnb(): """ check if we're inside an IPython Notebook - DEPRECATED: This is no longer used in pandas, and won't work in IPython 3 - and above. + .. deprecated:: 0.14.1 + This is no longer used in pandas, and won't work in IPython 3 and above. """ try: ip = get_ipython() # noqa diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 48cb1ca2ebd2a..26d1b4c070c77 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -3477,7 +3477,8 @@ def sort_index(self, axis=0, level=None, ascending=True, inplace=False, def sortlevel(self, level=0, axis=0, ascending=True, inplace=False, sort_remaining=True): """ - DEPRECATED: use :meth:`DataFrame.sort_index` + .. deprecated:: 0.20.0 + Use :meth:`DataFrame.sort_index` Sort multilevel index by chosen axis and primary level. Data will be lexicographically sorted by the chosen level followed by the other diff --git a/pandas/core/generic.py b/pandas/core/generic.py index da79912f7bd9e..c3d4e9f2c403a 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -1322,9 +1322,10 @@ def to_sql(self, name, con, flavor=None, schema=None, if_exists='fail', Using SQLAlchemy makes it possible to use any DB supported by that library. If a DBAPI2 object, only sqlite3 is supported. flavor : 'sqlite', default None - DEPRECATED: this parameter will be removed in a future version, - as 'sqlite' is the only supported option if SQLAlchemy is not - installed. + .. deprecated:: 0.19.0 + This parameter will be removed in a future version, + as 'sqlite' is the only supported option if SQLAlchemy is not + installed. schema : string, default None Specify the schema (if database flavor supports this). If None, use default schema. @@ -3162,7 +3163,8 @@ def _consolidate(self, inplace=False): def consolidate(self, inplace=False): """ - DEPRECATED: consolidate will be an internal implementation only. + .. deprecated:: 0.20.0 + Consolidate will be an internal implementation only. """ # 15483 warnings.warn("consolidate is deprecated and will be removed in a " @@ -3373,7 +3375,9 @@ def astype(self, dtype, copy=True, errors='raise', **kwargs): .. versionadded:: 0.20.0 - raise_on_error : DEPRECATED use ``errors`` instead + raise_on_error : raise on invalid input + .. deprecated:: 0.20.0 + Use ``errors`` instead kwargs : keyword arguments to pass on to the constructor Returns @@ -3476,7 +3480,7 @@ def _convert(self, datetime=False, numeric=False, timedelta=False, def convert_objects(self, convert_dates=True, convert_numeric=False, convert_timedeltas=True, copy=True): """ - Deprecated. + .. deprecated:: 0.18.0 Attempt to infer better dtype for object columns @@ -5684,8 +5688,9 @@ def tz_localize(self, tz, axis=0, level=None, copy=True, - 'NaT' will return NaT where there are ambiguous times - 'raise' will raise an AmbiguousTimeError if there are ambiguous times - infer_dst : boolean, default False (DEPRECATED) - Attempt to infer fall dst-transition hours based on order + infer_dst : boolean, default False + .. deprecated:: 0.15.0 + Attempt to infer fall dst-transition hours based on order Returns ------- diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 2af4f112ca941..a61897cf2c603 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -1008,7 +1008,8 @@ def _to_safe_for_reshape(self): def to_datetime(self, dayfirst=False): """ - DEPRECATED: use :meth:`pandas.to_datetime` instead. + .. deprecated:: 0.19.0 + Use :meth:`pandas.to_datetime` instead. For an Index containing strings or datetime.datetime objects, attempt conversion to DatetimeIndex diff --git a/pandas/core/indexes/datetimes.py b/pandas/core/indexes/datetimes.py index ec678b1577d81..3a80355e82261 100644 --- a/pandas/core/indexes/datetimes.py +++ b/pandas/core/indexes/datetimes.py @@ -197,8 +197,9 @@ class DatetimeIndex(DatelikeOps, TimelikeOps, DatetimeIndexOpsMixin, times) - 'NaT' will return NaT where there are ambiguous times - 'raise' will raise an AmbiguousTimeError if there are ambiguous times - infer_dst : boolean, default False (DEPRECATED) - Attempt to infer fall dst-transition hours based on order + infer_dst : boolean, default False + .. deprecated:: 0.15.0 + Attempt to infer fall dst-transition hours based on order name : object Name to be stored in the index @@ -1818,8 +1819,9 @@ def tz_localize(self, tz, ambiguous='raise', errors='raise'): .. versionadded:: 0.19.0 - infer_dst : boolean, default False (DEPRECATED) - Attempt to infer fall dst-transition hours based on order + infer_dst : boolean, default False + .. deprecated:: 0.15.0 + Attempt to infer fall dst-transition hours based on order Returns ------- diff --git a/pandas/core/indexes/period.py b/pandas/core/indexes/period.py index 15fd9b7dc2b6a..6965763f9e922 100644 --- a/pandas/core/indexes/period.py +++ b/pandas/core/indexes/period.py @@ -566,7 +566,8 @@ def asfreq(self, freq=None, how='E'): def to_datetime(self, dayfirst=False): """ - DEPRECATED: use :meth:`to_timestamp` instead. + .. deprecated:: + Use :meth:`to_timestamp` instead. Cast to DatetimeIndex. """ diff --git a/pandas/core/panel4d.py b/pandas/core/panel4d.py index f32de29c5c167..611a6826baedf 100644 --- a/pandas/core/panel4d.py +++ b/pandas/core/panel4d.py @@ -19,10 +19,11 @@ having 4 named dimensions. It is intended as a test bed for more N-Dimensional named containers. - DEPRECATED. Panel4D is deprecated and will be removed in a future version. - The recommended way to represent these types of n-dimensional data are with - the `xarray package `__. - Pandas provides a `.to_xarray()` method to automate this conversion. + .. deprecated:: 0.19.0 + Panel4D is deprecated and will be removed in a future version. + The recommended way to represent these types of n-dimensional data + are with the `xarray package `__. + Pandas provides a `.to_xarray()` method to automate this conversion. Parameters ---------- diff --git a/pandas/core/panelnd.py b/pandas/core/panelnd.py index 26ceeea654e4e..060f39561c321 100644 --- a/pandas/core/panelnd.py +++ b/pandas/core/panelnd.py @@ -9,10 +9,11 @@ def create_nd_panel_factory(klass_name, orders, slices, slicer, aliases=None, stat_axis=2, info_axis=0, ns=None): """ manufacture a n-d class: - DEPRECATED. Panelnd is deprecated and will be removed in a future version. - The recommended way to represent these types of n-dimensional data are with - the `xarray package `__. - Pandas provides a `.to_xarray()` method to automate this conversion. + .. deprecated:: 0.19.0 + Panelnd is deprecated and will be removed in a future version. + The recommended way to represent these types of n-dimensional data + are with the `xarray package `__. + Pandas provides a `.to_xarray()` method to automate this conversion. Parameters ---------- diff --git a/pandas/core/series.py b/pandas/core/series.py index 129f291e5f843..51ca79ef5cc8d 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -850,8 +850,9 @@ def repeat(self, repeats, *args, **kwargs): def reshape(self, *args, **kwargs): """ - DEPRECATED: calling this method will raise an error in a - future release. Please call ``.values.reshape(...)`` instead. + .. deprecated:: 0.19.0 + Calling this method will raise an error in a future release. + Please call ``.values.reshape(...)`` instead. return an ndarray with the values shape if the specified shape matches exactly the current shape, then @@ -1940,7 +1941,8 @@ def nsmallest(self, n=5, keep='first'): def sortlevel(self, level=0, ascending=True, sort_remaining=True): """ - DEPRECATED: use :meth:`Series.sort_index` + .. deprecated:: 0.20.0 + Use :meth:`Series.sort_index` Sort Series with MultiIndex by chosen level. Data will be lexicographically sorted by the chosen level followed by the other diff --git a/pandas/core/sparse/array.py b/pandas/core/sparse/array.py index 8ac9d3916573e..d7f510658dfdd 100644 --- a/pandas/core/sparse/array.py +++ b/pandas/core/sparse/array.py @@ -391,8 +391,9 @@ def to_dense(self, fill=None): Parameters ---------- fill: float, default None - DEPRECATED: this argument will be removed in a future version - because it is not respected by this function. + .. deprecated:: 0.20.0 + This argument will be removed in a future version + because it is not respected by this function. Returns ------- diff --git a/pandas/core/strings.py b/pandas/core/strings.py index c57d7a9362490..fa68b61f7cf3f 100644 --- a/pandas/core/strings.py +++ b/pandas/core/strings.py @@ -478,7 +478,10 @@ def str_match(arr, pat, case=True, flags=0, na=np.nan, as_indexer=None): flags : int, default 0 (no flags) re module flags, e.g. re.IGNORECASE na : default NaN, fill value for missing values. - as_indexer : DEPRECATED + as_indexer : False, by default, gives deprecated behavior better + achieved using str_extract. True return boolean indexer. + .. deprecated:: 0.20.0 + Keyword is ignored Returns ------- diff --git a/pandas/core/window.py b/pandas/core/window.py index cf1bad706ae1d..d8c362b454f79 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -341,21 +341,23 @@ def aggregate(self, arg, *args, **kwargs): Parameters ---------- - how : string, default None (DEPRECATED) - Method for down- or re-sampling""") + how : string, default None + .. deprecated:: 0.18.0 + Method for down- or re-sampling""") _shared_docs['mean'] = dedent(""" %(name)s mean Parameters ---------- - how : string, default None (DEPRECATED) - Method for down- or re-sampling""") + how : string, default None + .. deprecated:: 0.18.0 + Method for down- or re-sampling""") class Window(_Window): """ - Provides rolling window calculcations. + Provides rolling window calculations. .. versionadded:: 0.18.0 @@ -373,9 +375,10 @@ class Window(_Window): Minimum number of observations in window required to have a value (otherwise result is NA). For a window that is specified by an offset, this will default to 1. - freq : string or DateOffset object, optional (default None) (DEPRECATED) - Frequency to conform the data to before computing the statistic. - Specified as a frequency string or DateOffset object. + freq : string or DateOffset object, optional (default None) + .. deprecated:: 0.18.0 + Frequency to conform the data to before computing the statistic. + Specified as a frequency string or DateOffset object. center : boolean, default False Set the labels at the center of the window. win_type : string, default None @@ -570,8 +573,9 @@ def _apply_window(self, mean=True, how=None, **kwargs): ---------- mean : boolean, default True If True computes weighted mean, else weighted sum - how : string, default to None (DEPRECATED) - how to resample + how : string, default to None + .. deprecated:: 0.18.0 + how to resample Returns ------- @@ -735,8 +739,9 @@ def _apply(self, func, name=None, window=None, center=None, window : int/array, default to _get_window() center : boolean, default to self.center check_minp : function, default to _use_window - how : string, default to None (DEPRECATED) - how to resample + how : string, default to None + .. deprecated:: 0.18.0 + how to resample Returns ------- @@ -863,8 +868,9 @@ def sum(self, *args, **kwargs): Parameters ---------- - how : string, default 'max' (DEPRECATED) - Method for down- or re-sampling""") + how : string, default 'max' + .. deprecated:: 0.18.0 + Method for down- or re-sampling""") def max(self, how=None, *args, **kwargs): nv.validate_window_func('max', args, kwargs) @@ -877,8 +883,9 @@ def max(self, how=None, *args, **kwargs): Parameters ---------- - how : string, default 'min' (DEPRECATED) - Method for down- or re-sampling""") + how : string, default 'min' + .. deprecated:: 0.18.0 + Method for down- or re-sampling""") def min(self, how=None, *args, **kwargs): nv.validate_window_func('min', args, kwargs) @@ -895,8 +902,9 @@ def mean(self, *args, **kwargs): Parameters ---------- - how : string, default 'median' (DEPRECATED) - Method for down- or re-sampling""") + how : string, default 'median' + .. deprecated:: 0.18.0 + Method for down- or re-sampling""") def median(self, how=None, **kwargs): if self.freq is not None and how is None: @@ -1322,9 +1330,10 @@ class Expanding(_Rolling_and_Expanding): min_periods : int, default None Minimum number of observations in window required to have a value (otherwise result is NA). - freq : string or DateOffset object, optional (default None) (DEPRECATED) - Frequency to conform the data to before computing the statistic. - Specified as a frequency string or DateOffset object. + freq : string or DateOffset object, optional (default None) + .. deprecated:: 0.18.0 + Frequency to conform the data to before computing the statistic. + Specified as a frequency string or DateOffset object. center : boolean, default False Set the labels at the center of the window. axis : int or string, default 0 @@ -1586,8 +1595,9 @@ class EWM(_Rolling): min_periods : int, default 0 Minimum number of observations in window required to have a value (otherwise result is NA). - freq : None or string alias / date offset object, default=None (DEPRECATED) - Frequency to conform to before computing statistic + freq : None or string alias / date offset object, default=None + .. deprecated:: 0.18.0 + Frequency to conform to before computing statistic adjust : boolean, default True Divide by decaying adjustment factor in beginning periods to account for imbalance in relative weightings (viewing EWMA as a moving average) @@ -1720,8 +1730,9 @@ def _apply(self, func, how=None, **kwargs): Parameters ---------- func : string/callable to apply - how : string, default to None (DEPRECATED) - how to resample + how : string, default to None + .. deprecated:: 0.18.0 + how to resample Returns ------- diff --git a/pandas/io/excel.py b/pandas/io/excel.py index 81a36b21b3617..e4f5655b47411 100644 --- a/pandas/io/excel.py +++ b/pandas/io/excel.py @@ -141,9 +141,10 @@ data will be read in as floats: Excel stores all numbers as floats internally has_index_names : boolean, default None - DEPRECATED: for version 0.17+ index names will be automatically - inferred based on index_col. To read Excel output from 0.16.2 and - prior that had saved index names, use True. + .. deprecated:: 0.17.0 + For version 0.17+ index names will be automatically + inferred based on index_col. To read Excel output from 0.16.2 and + prior that had saved index names, use True. Returns ------- diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py index e287d92f67ef6..a7d1f0e9c25ac 100755 --- a/pandas/io/parsers.py +++ b/pandas/io/parsers.py @@ -105,8 +105,9 @@ ['AAA', 'BBB', 'DDD']``. Using this parameter results in much faster parsing time and lower memory usage. as_recarray : boolean, default False - DEPRECATED: this argument will be removed in a future version. Please call - `pd.read_csv(...).to_records()` instead. + .. deprecated:: 0.19.0 + This argument will be removed in a future version. Please call + `pd.read_csv(...).to_records()` instead. Return a NumPy recarray instead of a DataFrame after parsing the data. If set to True, this option takes precedence over the `squeeze` parameter. @@ -145,7 +146,8 @@ skipfooter : int, default 0 Number of lines at bottom of file to skip (Unsupported with engine='c') skip_footer : int, default 0 - DEPRECATED: use the `skipfooter` parameter instead, as they are identical + .. deprecated:: 0.19.0 + Use the `skipfooter` parameter instead, as they are identical nrows : int, default None Number of rows of file to read. Useful for reading pieces of large files na_values : scalar, str, list-like, or dict, default None @@ -276,17 +278,20 @@ use the `chunksize` or `iterator` parameter to return the data in chunks. (Only valid with C parser) buffer_lines : int, default None - DEPRECATED: this argument will be removed in a future version because its - value is not respected by the parser + .. deprecated:: 0.19.0 + This argument will be removed in a future version because its + value is not respected by the parser compact_ints : boolean, default False - DEPRECATED: this argument will be removed in a future version + .. deprecated:: 0.19.0 + This argument will be removed in a future version If compact_ints is True, then for any column that is of integer dtype, the parser will attempt to cast it as the smallest integer dtype possible, either signed or unsigned depending on the specification from the `use_unsigned` parameter. use_unsigned : boolean, default False - DEPRECATED: this argument will be removed in a future version + .. deprecated:: 0.19.0 + This argument will be removed in a future version If integer columns are being compacted (i.e. `compact_ints=True`), specify whether the column should be compacted to the smallest signed or unsigned diff --git a/pandas/io/sql.py b/pandas/io/sql.py index ee992c6dd3439..90e1cae683c1e 100644 --- a/pandas/io/sql.py +++ b/pandas/io/sql.py @@ -432,7 +432,8 @@ def to_sql(frame, name, con, flavor=None, schema=None, if_exists='fail', library. If a DBAPI2 object, only sqlite3 is supported. flavor : 'sqlite', default None - DEPRECATED: this parameter will be removed in a future version + .. deprecated:: 0.19.0 + This parameter will be removed in a future version schema : string, default None Name of SQL schema in database to write to (if database flavor supports this). If None, use default schema (default). @@ -484,7 +485,8 @@ def has_table(table_name, con, flavor=None, schema=None): library. If a DBAPI2 object, only sqlite3 is supported. flavor : 'sqlite', default None - DEPRECATED: this parameter will be removed in a future version + .. deprecated:: 0.19.0 + This parameter will be removed in a future version schema : string, default None Name of SQL schema in database to write to (if database flavor supports this). If None, use default schema (default). @@ -1545,7 +1547,8 @@ def get_schema(frame, name, flavor=None, keys=None, con=None, dtype=None): library, default: None If a DBAPI2 object, only sqlite3 is supported. flavor : 'sqlite', default None - DEPRECATED: this parameter will be removed in a future version + .. deprecated:: 0.19.0 + This parameter will be removed in a future version dtype : dict of column name to SQL type, default None Optional specifying the datatype for columns. The SQL type should be a SQLAlchemy type, or a string for sqlite3 fallback connection. diff --git a/pandas/io/stata.py b/pandas/io/stata.py index e03e87f09173e..107dccfc8175c 100644 --- a/pandas/io/stata.py +++ b/pandas/io/stata.py @@ -110,9 +110,11 @@ _statafile_processing_params2, _chunksize_params, _iterator_params) -_data_method_doc = """Reads observations from Stata file, converting them into a dataframe +_data_method_doc = """\ +Reads observations from Stata file, converting them into a dataframe -This is a legacy method. Use `read` in new code. + .. deprecated:: + This is a legacy method. Use `read` in new code. Parameters ---------- @@ -1407,7 +1409,7 @@ def _read_strls(self): self.GSO[str(v_o)] = va # legacy - @Appender('DEPRECATED: ' + _data_method_doc) + @Appender(_data_method_doc) def data(self, **kwargs): import warnings From 400bb404f92fb461a26b5db92ee970358f346dc8 Mon Sep 17 00:00:00 2001 From: sfoo Date: Fri, 26 May 2017 00:06:17 -0700 Subject: [PATCH 2/6] Fixed whitespace --- pandas/core/indexes/period.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/indexes/period.py b/pandas/core/indexes/period.py index 6965763f9e922..fb9002d34ccd2 100644 --- a/pandas/core/indexes/period.py +++ b/pandas/core/indexes/period.py @@ -566,7 +566,7 @@ def asfreq(self, freq=None, how='E'): def to_datetime(self, dayfirst=False): """ - .. deprecated:: + .. deprecated:: 0.19.0 Use :meth:`to_timestamp` instead. Cast to DatetimeIndex. From 135f8d0939c94549c1db6bfd069e31ae14298115 Mon Sep 17 00:00:00 2001 From: sfoo Date: Tue, 30 May 2017 18:19:51 -0700 Subject: [PATCH 3/6] Removed references to future versions --- doc/source/io.rst | 14 ++++++-------- pandas/core/categorical.py | 2 +- pandas/core/common.py | 2 +- pandas/core/generic.py | 3 +-- pandas/core/panel4d.py | 1 - pandas/core/panelnd.py | 1 - pandas/core/series.py | 4 ++-- pandas/core/sparse/array.py | 3 +-- pandas/io/parsers.py | 10 ++++------ pandas/io/sql.py | 9 ++++++--- 10 files changed, 22 insertions(+), 27 deletions(-) diff --git a/doc/source/io.rst b/doc/source/io.rst index 73ce45dee2cfa..52d57e1d1f49b 100644 --- a/doc/source/io.rst +++ b/doc/source/io.rst @@ -138,8 +138,7 @@ usecols : array-like or callable, default ``None`` Using this parameter results in much faster parsing time and lower memory usage. as_recarray : boolean, default ``False`` .. deprecated:: 0.18.2 - This argument will be removed in a future version. Please call - ``pd.read_csv(...).to_records()`` instead. + Please call ``pd.read_csv(...).to_records()`` instead. Return a NumPy recarray instead of a DataFrame after parsing the data. If set to ``True``, this option takes precedence over the ``squeeze`` parameter. @@ -204,19 +203,18 @@ low_memory : boolean, default ``True`` use the ``chunksize`` or ``iterator`` parameter to return the data in chunks. (Only valid with C parser) buffer_lines : int, default None - .. deprecated:: 0.18.2 - This argument will be removed in a future version because its - value is not respected by the parser + .. deprecated:: 0.19.0 + Argument removed because its value is not respected by the parser compact_ints : boolean, default False - .. deprecated:: 0.18.2 - DEPRECATED: this argument will be removed in a future version + .. deprecated:: 0.19.0 + Argument moved to ``pd.to_numeric`` If ``compact_ints`` is ``True``, then for any column that is of integer dtype, the parser will attempt to cast it as the smallest integer ``dtype`` possible, either signed or unsigned depending on the specification from the ``use_unsigned`` parameter. use_unsigned : boolean, default False .. deprecated:: 0.18.2 - This argument will be removed in a future version + Argument moved to ``pd.to_numeric`` If integer columns are being compacted (i.e. ``compact_ints=True``), specify whether the column should be compacted to the smallest signed or unsigned integer dtype. diff --git a/pandas/core/categorical.py b/pandas/core/categorical.py index 96cb4f124c1a9..83b3852a8eef8 100644 --- a/pandas/core/categorical.py +++ b/pandas/core/categorical.py @@ -423,7 +423,7 @@ def base(self): @classmethod def from_array(cls, data, **kwargs): """ - .. deprecated:: + .. deprecated:: 0.19.0 Use ``Categorical`` instead. Make a Categorical type from a single array-like object. diff --git a/pandas/core/common.py b/pandas/core/common.py index fa34b80cd30e0..5e66f913c2930 100644 --- a/pandas/core/common.py +++ b/pandas/core/common.py @@ -568,7 +568,7 @@ def in_ipnb(): check if we're inside an IPython Notebook .. deprecated:: 0.14.1 - This is no longer used in pandas, and won't work in IPython 3 and above. + This is no longer needed, or working, in IPython 3 and above. """ try: ip = get_ipython() # noqa diff --git a/pandas/core/generic.py b/pandas/core/generic.py index c3d4e9f2c403a..0c47aad734c6d 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -1323,8 +1323,7 @@ def to_sql(self, name, con, flavor=None, schema=None, if_exists='fail', library. If a DBAPI2 object, only sqlite3 is supported. flavor : 'sqlite', default None .. deprecated:: 0.19.0 - This parameter will be removed in a future version, - as 'sqlite' is the only supported option if SQLAlchemy is not + 'sqlite' is the only supported option if SQLAlchemy is not installed. schema : string, default None Specify the schema (if database flavor supports this). If None, use diff --git a/pandas/core/panel4d.py b/pandas/core/panel4d.py index 611a6826baedf..16e7d0dfcc336 100644 --- a/pandas/core/panel4d.py +++ b/pandas/core/panel4d.py @@ -20,7 +20,6 @@ N-Dimensional named containers. .. deprecated:: 0.19.0 - Panel4D is deprecated and will be removed in a future version. The recommended way to represent these types of n-dimensional data are with the `xarray package `__. Pandas provides a `.to_xarray()` method to automate this conversion. diff --git a/pandas/core/panelnd.py b/pandas/core/panelnd.py index 060f39561c321..7a5cb63cd4f07 100644 --- a/pandas/core/panelnd.py +++ b/pandas/core/panelnd.py @@ -10,7 +10,6 @@ def create_nd_panel_factory(klass_name, orders, slices, slicer, aliases=None, """ manufacture a n-d class: .. deprecated:: 0.19.0 - Panelnd is deprecated and will be removed in a future version. The recommended way to represent these types of n-dimensional data are with the `xarray package `__. Pandas provides a `.to_xarray()` method to automate this conversion. diff --git a/pandas/core/series.py b/pandas/core/series.py index 51ca79ef5cc8d..4dfe07aae0eb4 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -851,8 +851,8 @@ def repeat(self, repeats, *args, **kwargs): def reshape(self, *args, **kwargs): """ .. deprecated:: 0.19.0 - Calling this method will raise an error in a future release. - Please call ``.values.reshape(...)`` instead. + Calling this method will raise an error. Please call + ``.values.reshape(...)`` instead. return an ndarray with the values shape if the specified shape matches exactly the current shape, then diff --git a/pandas/core/sparse/array.py b/pandas/core/sparse/array.py index d7f510658dfdd..bdcec990cfe2c 100644 --- a/pandas/core/sparse/array.py +++ b/pandas/core/sparse/array.py @@ -392,8 +392,7 @@ def to_dense(self, fill=None): ---------- fill: float, default None .. deprecated:: 0.20.0 - This argument will be removed in a future version - because it is not respected by this function. + This argument is not respected by this function. Returns ------- diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py index a7d1f0e9c25ac..91175bf178d48 100755 --- a/pandas/io/parsers.py +++ b/pandas/io/parsers.py @@ -106,8 +106,7 @@ parsing time and lower memory usage. as_recarray : boolean, default False .. deprecated:: 0.19.0 - This argument will be removed in a future version. Please call - `pd.read_csv(...).to_records()` instead. + Please call `pd.read_csv(...).to_records()` instead. Return a NumPy recarray instead of a DataFrame after parsing the data. If set to True, this option takes precedence over the `squeeze` parameter. @@ -279,11 +278,10 @@ (Only valid with C parser) buffer_lines : int, default None .. deprecated:: 0.19.0 - This argument will be removed in a future version because its - value is not respected by the parser + This argument is not respected by the parser compact_ints : boolean, default False .. deprecated:: 0.19.0 - This argument will be removed in a future version + Argument moved to ``pd.to_numeric`` If compact_ints is True, then for any column that is of integer dtype, the parser will attempt to cast it as the smallest integer dtype possible, @@ -291,7 +289,7 @@ `use_unsigned` parameter. use_unsigned : boolean, default False .. deprecated:: 0.19.0 - This argument will be removed in a future version + Argument moved to ``pd.to_numeric`` If integer columns are being compacted (i.e. `compact_ints=True`), specify whether the column should be compacted to the smallest signed or unsigned diff --git a/pandas/io/sql.py b/pandas/io/sql.py index 90e1cae683c1e..8fb28d2dedc68 100644 --- a/pandas/io/sql.py +++ b/pandas/io/sql.py @@ -433,7 +433,8 @@ def to_sql(frame, name, con, flavor=None, schema=None, if_exists='fail', If a DBAPI2 object, only sqlite3 is supported. flavor : 'sqlite', default None .. deprecated:: 0.19.0 - This parameter will be removed in a future version + 'sqlite' is the only supported option if SQLAlchemy is not + installed. schema : string, default None Name of SQL schema in database to write to (if database flavor supports this). If None, use default schema (default). @@ -486,7 +487,8 @@ def has_table(table_name, con, flavor=None, schema=None): If a DBAPI2 object, only sqlite3 is supported. flavor : 'sqlite', default None .. deprecated:: 0.19.0 - This parameter will be removed in a future version + 'sqlite' is the only supported option if SQLAlchemy is not + installed. schema : string, default None Name of SQL schema in database to write to (if database flavor supports this). If None, use default schema (default). @@ -1548,7 +1550,8 @@ def get_schema(frame, name, flavor=None, keys=None, con=None, dtype=None): If a DBAPI2 object, only sqlite3 is supported. flavor : 'sqlite', default None .. deprecated:: 0.19.0 - This parameter will be removed in a future version + 'sqlite' is the only supported option if SQLAlchemy is not + installed. dtype : dict of column name to SQL type, default None Optional specifying the datatype for columns. The SQL type should be a SQLAlchemy type, or a string for sqlite3 fallback connection. From 7fccb78c0002030b840d57d2be395d4c2975871a Mon Sep 17 00:00:00 2001 From: sfoo Date: Thu, 15 Jun 2017 11:14:22 -0400 Subject: [PATCH 4/6] Updated per comments --- doc/source/io.rst | 12 + doc/source/style.ipynb | 1185 ---------------------------------------- 2 files changed, 12 insertions(+), 1185 deletions(-) delete mode 100644 doc/source/style.ipynb diff --git a/doc/source/io.rst b/doc/source/io.rst index 52d57e1d1f49b..cd39fac15d0ba 100644 --- a/doc/source/io.rst +++ b/doc/source/io.rst @@ -137,7 +137,9 @@ usecols : array-like or callable, default ``None`` Using this parameter results in much faster parsing time and lower memory usage. as_recarray : boolean, default ``False`` + .. deprecated:: 0.18.2 + Please call ``pd.read_csv(...).to_records()`` instead. Return a NumPy recarray instead of a DataFrame after parsing the data. If @@ -191,8 +193,11 @@ skiprows : list-like or integer, default ``None`` skipfooter : int, default ``0`` Number of lines at bottom of file to skip (unsupported with engine='c'). skip_footer : int, default ``0`` + .. deprecated:: 0.19.0 + Use the ``skipfooter`` parameter instead, as they are identical + nrows : int, default ``None`` Number of rows of file to read. Useful for reading pieces of large files. low_memory : boolean, default ``True`` @@ -203,17 +208,24 @@ low_memory : boolean, default ``True`` use the ``chunksize`` or ``iterator`` parameter to return the data in chunks. (Only valid with C parser) buffer_lines : int, default None + .. deprecated:: 0.19.0 + Argument removed because its value is not respected by the parser + compact_ints : boolean, default False + .. deprecated:: 0.19.0 + Argument moved to ``pd.to_numeric`` If ``compact_ints`` is ``True``, then for any column that is of integer dtype, the parser will attempt to cast it as the smallest integer ``dtype`` possible, either signed or unsigned depending on the specification from the ``use_unsigned`` parameter. use_unsigned : boolean, default False + .. deprecated:: 0.18.2 + Argument moved to ``pd.to_numeric`` If integer columns are being compacted (i.e. ``compact_ints=True``), specify whether diff --git a/doc/source/style.ipynb b/doc/source/style.ipynb deleted file mode 100644 index 4eeda491426b1..0000000000000 --- a/doc/source/style.ipynb +++ /dev/null @@ -1,1185 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "# Styling\n", - "\n", - "*New in version 0.17.1*\n", - "\n", - "*Provisional: This is a new feature and still under development. We'll be adding features and possibly making breaking changes in future releases. We'd love to hear your feedback.*\n", - "\n", - "This document is written as a Jupyter Notebook, and can be viewed or downloaded [here](http://nbviewer.ipython.org/github/pandas-dev/pandas/blob/master/doc/source/style.ipynb).\n", - "\n", - "You can apply **conditional formatting**, the visual styling of a DataFrame\n", - "depending on the data within, by using the ``DataFrame.style`` property.\n", - "This is a property that returns a ``Styler`` object, which has\n", - "useful methods for formatting and displaying DataFrames.\n", - "\n", - "The styling is accomplished using CSS.\n", - "You write \"style functions\" that take scalars, `DataFrame`s or `Series`, and return *like-indexed* DataFrames or Series with CSS `\"attribute: value\"` pairs for the values.\n", - "These functions can be incrementally passed to the `Styler` which collects the styles before rendering." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Building Styles\n", - "\n", - "Pass your style functions into one of the following methods:\n", - "\n", - "- ``Styler.applymap``: elementwise\n", - "- ``Styler.apply``: column-/row-/table-wise\n", - "\n", - "Both of those methods take a function (and some other keyword arguments) and applies your function to the DataFrame in a certain way.\n", - "`Styler.applymap` works through the DataFrame elementwise.\n", - "`Styler.apply` passes each column or row into your DataFrame one-at-a-time or the entire table at once, depending on the `axis` keyword argument.\n", - "For columnwise use `axis=0`, rowwise use `axis=1`, and for the entire table at once use `axis=None`.\n", - "\n", - "For `Styler.applymap` your function should take a scalar and return a single string with the CSS attribute-value pair.\n", - "\n", - "For `Styler.apply` your function should take a Series or DataFrame (depending on the axis parameter), and return a Series or DataFrame with an identical shape where each value is a string with a CSS attribute-value pair.\n", - "\n", - "Let's see some examples." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true, - "nbsphinx": "hidden" - }, - "outputs": [], - "source": [ - "import matplotlib.pyplot\n", - "# We have this here to trigger matplotlib's font cache stuff.\n", - "# This cell is hidden from the output" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "import pandas as pd\n", - "import numpy as np\n", - "\n", - "np.random.seed(24)\n", - "df = pd.DataFrame({'A': np.linspace(1, 10, 10)})\n", - "df = pd.concat([df, pd.DataFrame(np.random.randn(10, 4), columns=list('BCDE'))],\n", - " axis=1)\n", - "df.iloc[0, 2] = np.nan" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Here's a boring example of rendering a DataFrame, without any (visible) styles:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "df.style" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "*Note*: The `DataFrame.style` attribute is a property that returns a `Styler` object. `Styler` has a `_repr_html_` method defined on it so they are rendered automatically. If you want the actual HTML back for further processing or for writing to file call the `.render()` method which returns a string.\n", - "\n", - "The above output looks very similar to the standard DataFrame HTML representation. But we've done some work behind the scenes to attach CSS classes to each cell. We can view these by calling the `.render` method." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "df.style.highlight_null().render().split('\\n')[:10]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The `row0_col2` is the identifier for that particular cell. We've also prepended each row/column identifier with a UUID unique to each DataFrame so that the style from one doesn't collide with the styling from another within the same notebook or page (you can set the `uuid` if you'd like to tie together the styling of two DataFrames).\n", - "\n", - "When writing style functions, you take care of producing the CSS attribute / value pairs you want. Pandas matches those up with the CSS classes that identify each cell." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Let's write a simple style function that will color negative numbers red and positive numbers black." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "def color_negative_red(val):\n", - " \"\"\"\n", - " Takes a scalar and returns a string with\n", - " the css property `'color: red'` for negative\n", - " strings, black otherwise.\n", - " \"\"\"\n", - " color = 'red' if val < 0 else 'black'\n", - " return 'color: %s' % color" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In this case, the cell's style depends only on it's own value.\n", - "That means we should use the `Styler.applymap` method which works elementwise." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "s = df.style.applymap(color_negative_red)\n", - "s" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Notice the similarity with the standard `df.applymap`, which operates on DataFrames elementwise. We want you to be able to resuse your existing knowledge of how to interact with DataFrames.\n", - "\n", - "Notice also that our function returned a string containing the CSS attribute and value, separated by a colon just like in a `'.format(css))" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.6.1" - } - }, - "nbformat": 4, - "nbformat_minor": 1 -} From 9f945c2878352f3478eba10a8a327448b6690204 Mon Sep 17 00:00:00 2001 From: sfoo Date: Thu, 15 Jun 2017 11:17:05 -0400 Subject: [PATCH 5/6] Rendered HTML using sphinx to check output --- doc/sphinxext/numpydoc/README.rst | 4 +--- pandas/_libs/tslib.pyx | 3 +-- pandas/core/frame.py | 3 +-- pandas/core/generic.py | 2 -- pandas/core/indexes/base.py | 3 +-- 5 files changed, 4 insertions(+), 11 deletions(-) diff --git a/doc/sphinxext/numpydoc/README.rst b/doc/sphinxext/numpydoc/README.rst index eff87a4473e56..f91811ef9add6 100755 --- a/doc/sphinxext/numpydoc/README.rst +++ b/doc/sphinxext/numpydoc/README.rst @@ -46,8 +46,6 @@ The following options can be set in conf.py: methods and attributes. If a table of contents is made, Sphinx expects each entry to have a separate page. -- numpydoc_edit_link: bool - .. deprecated:: - Edit your HTML template instead +- numpydoc_edit_link: bool (DEPRECATED -- edit your HTML template instead) Whether to insert an edit link after docstrings. diff --git a/pandas/_libs/tslib.pyx b/pandas/_libs/tslib.pyx index 28e7d02819d44..c471d46262484 100644 --- a/pandas/_libs/tslib.pyx +++ b/pandas/_libs/tslib.pyx @@ -1148,8 +1148,7 @@ cdef class _Timestamp(datetime): cpdef datetime to_datetime(_Timestamp self): """ - .. deprecated:: 0.19.0 - Use :meth:`to_pydatetime` instead. + DEPRECATED: use :meth:`to_pydatetime` instead. Convert a Timestamp object to a native Python datetime object. """ diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 26d1b4c070c77..48cb1ca2ebd2a 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -3477,8 +3477,7 @@ def sort_index(self, axis=0, level=None, ascending=True, inplace=False, def sortlevel(self, level=0, axis=0, ascending=True, inplace=False, sort_remaining=True): """ - .. deprecated:: 0.20.0 - Use :meth:`DataFrame.sort_index` + DEPRECATED: use :meth:`DataFrame.sort_index` Sort multilevel index by chosen axis and primary level. Data will be lexicographically sorted by the chosen level followed by the other diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 0c47aad734c6d..a0a9ddb82a6aa 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -3479,8 +3479,6 @@ def _convert(self, datetime=False, numeric=False, timedelta=False, def convert_objects(self, convert_dates=True, convert_numeric=False, convert_timedeltas=True, copy=True): """ - .. deprecated:: 0.18.0 - Attempt to infer better dtype for object columns Parameters diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index a61897cf2c603..2af4f112ca941 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -1008,8 +1008,7 @@ def _to_safe_for_reshape(self): def to_datetime(self, dayfirst=False): """ - .. deprecated:: 0.19.0 - Use :meth:`pandas.to_datetime` instead. + DEPRECATED: use :meth:`pandas.to_datetime` instead. For an Index containing strings or datetime.datetime objects, attempt conversion to DatetimeIndex From 4dcab50693f82c51605459873c605d40db7e9efc Mon Sep 17 00:00:00 2001 From: sfoo Date: Sun, 25 Jun 2017 14:24:10 -0400 Subject: [PATCH 6/6] Restored deleted file; updated per comments --- doc/source/style.ipynb | 1185 ++++++++++++++++++++++++++++++++++++++++ pandas/core/generic.py | 6 +- pandas/core/series.py | 3 +- pandas/core/strings.py | 5 +- pandas/io/sql.py | 2 +- 5 files changed, 1191 insertions(+), 10 deletions(-) create mode 100644 doc/source/style.ipynb diff --git a/doc/source/style.ipynb b/doc/source/style.ipynb new file mode 100644 index 0000000000000..4eeda491426b1 --- /dev/null +++ b/doc/source/style.ipynb @@ -0,0 +1,1185 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "# Styling\n", + "\n", + "*New in version 0.17.1*\n", + "\n", + "*Provisional: This is a new feature and still under development. We'll be adding features and possibly making breaking changes in future releases. We'd love to hear your feedback.*\n", + "\n", + "This document is written as a Jupyter Notebook, and can be viewed or downloaded [here](http://nbviewer.ipython.org/github/pandas-dev/pandas/blob/master/doc/source/style.ipynb).\n", + "\n", + "You can apply **conditional formatting**, the visual styling of a DataFrame\n", + "depending on the data within, by using the ``DataFrame.style`` property.\n", + "This is a property that returns a ``Styler`` object, which has\n", + "useful methods for formatting and displaying DataFrames.\n", + "\n", + "The styling is accomplished using CSS.\n", + "You write \"style functions\" that take scalars, `DataFrame`s or `Series`, and return *like-indexed* DataFrames or Series with CSS `\"attribute: value\"` pairs for the values.\n", + "These functions can be incrementally passed to the `Styler` which collects the styles before rendering." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Building Styles\n", + "\n", + "Pass your style functions into one of the following methods:\n", + "\n", + "- ``Styler.applymap``: elementwise\n", + "- ``Styler.apply``: column-/row-/table-wise\n", + "\n", + "Both of those methods take a function (and some other keyword arguments) and applies your function to the DataFrame in a certain way.\n", + "`Styler.applymap` works through the DataFrame elementwise.\n", + "`Styler.apply` passes each column or row into your DataFrame one-at-a-time or the entire table at once, depending on the `axis` keyword argument.\n", + "For columnwise use `axis=0`, rowwise use `axis=1`, and for the entire table at once use `axis=None`.\n", + "\n", + "For `Styler.applymap` your function should take a scalar and return a single string with the CSS attribute-value pair.\n", + "\n", + "For `Styler.apply` your function should take a Series or DataFrame (depending on the axis parameter), and return a Series or DataFrame with an identical shape where each value is a string with a CSS attribute-value pair.\n", + "\n", + "Let's see some examples." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true, + "nbsphinx": "hidden" + }, + "outputs": [], + "source": [ + "import matplotlib.pyplot\n", + "# We have this here to trigger matplotlib's font cache stuff.\n", + "# This cell is hidden from the output" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "import pandas as pd\n", + "import numpy as np\n", + "\n", + "np.random.seed(24)\n", + "df = pd.DataFrame({'A': np.linspace(1, 10, 10)})\n", + "df = pd.concat([df, pd.DataFrame(np.random.randn(10, 4), columns=list('BCDE'))],\n", + " axis=1)\n", + "df.iloc[0, 2] = np.nan" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Here's a boring example of rendering a DataFrame, without any (visible) styles:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "df.style" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "*Note*: The `DataFrame.style` attribute is a property that returns a `Styler` object. `Styler` has a `_repr_html_` method defined on it so they are rendered automatically. If you want the actual HTML back for further processing or for writing to file call the `.render()` method which returns a string.\n", + "\n", + "The above output looks very similar to the standard DataFrame HTML representation. But we've done some work behind the scenes to attach CSS classes to each cell. We can view these by calling the `.render` method." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "df.style.highlight_null().render().split('\\n')[:10]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The `row0_col2` is the identifier for that particular cell. We've also prepended each row/column identifier with a UUID unique to each DataFrame so that the style from one doesn't collide with the styling from another within the same notebook or page (you can set the `uuid` if you'd like to tie together the styling of two DataFrames).\n", + "\n", + "When writing style functions, you take care of producing the CSS attribute / value pairs you want. Pandas matches those up with the CSS classes that identify each cell." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Let's write a simple style function that will color negative numbers red and positive numbers black." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def color_negative_red(val):\n", + " \"\"\"\n", + " Takes a scalar and returns a string with\n", + " the css property `'color: red'` for negative\n", + " strings, black otherwise.\n", + " \"\"\"\n", + " color = 'red' if val < 0 else 'black'\n", + " return 'color: %s' % color" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In this case, the cell's style depends only on it's own value.\n", + "That means we should use the `Styler.applymap` method which works elementwise." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "s = df.style.applymap(color_negative_red)\n", + "s" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Notice the similarity with the standard `df.applymap`, which operates on DataFrames elementwise. We want you to be able to resuse your existing knowledge of how to interact with DataFrames.\n", + "\n", + "Notice also that our function returned a string containing the CSS attribute and value, separated by a colon just like in a `'.format(css))" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.6.1" + } + }, + "nbformat": 4, + "nbformat_minor": 1 +} diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 9828530b77ac5..5f2165b374ad5 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -1340,7 +1340,7 @@ def to_sql(self, name, con, flavor=None, schema=None, if_exists='fail', flavor : 'sqlite', default None .. deprecated:: 0.19.0 'sqlite' is the only supported option if SQLAlchemy is not - installed. + used. schema : string, default None Specify the schema (if database flavor supports this). If None, use default schema. @@ -3287,8 +3287,7 @@ def _consolidate(self, inplace=False): def consolidate(self, inplace=False): """ - .. deprecated:: 0.20.0 - Consolidate will be an internal implementation only. + DEPRECATED: consolidate will be an internal implementation only. """ # 15483 warnings.warn("consolidate is deprecated and will be removed in a " @@ -3604,6 +3603,7 @@ def _convert(self, datetime=False, numeric=False, timedelta=False, def convert_objects(self, convert_dates=True, convert_numeric=False, convert_timedeltas=True, copy=True): """ + Deprecated. Attempt to infer better dtype for object columns Parameters diff --git a/pandas/core/series.py b/pandas/core/series.py index 4dfe07aae0eb4..7d0c7afb4b80a 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -1941,8 +1941,7 @@ def nsmallest(self, n=5, keep='first'): def sortlevel(self, level=0, ascending=True, sort_remaining=True): """ - .. deprecated:: 0.20.0 - Use :meth:`Series.sort_index` + DEPRECATED: use :meth:`Series.sort_index` Sort Series with MultiIndex by chosen level. Data will be lexicographically sorted by the chosen level followed by the other diff --git a/pandas/core/strings.py b/pandas/core/strings.py index ecf74ffa72f48..cd7e313b13f1e 100644 --- a/pandas/core/strings.py +++ b/pandas/core/strings.py @@ -478,10 +478,7 @@ def str_match(arr, pat, case=True, flags=0, na=np.nan, as_indexer=None): flags : int, default 0 (no flags) re module flags, e.g. re.IGNORECASE na : default NaN, fill value for missing values. - as_indexer : False, by default, gives deprecated behavior better - achieved using str_extract. True return boolean indexer. - .. deprecated:: 0.20.0 - Keyword is ignored + as_indexer : DEPRECATED - Keyword is ignored. Returns ------- diff --git a/pandas/io/sql.py b/pandas/io/sql.py index 8fb28d2dedc68..0dbef66616e43 100644 --- a/pandas/io/sql.py +++ b/pandas/io/sql.py @@ -434,7 +434,7 @@ def to_sql(frame, name, con, flavor=None, schema=None, if_exists='fail', flavor : 'sqlite', default None .. deprecated:: 0.19.0 'sqlite' is the only supported option if SQLAlchemy is not - installed. + used. schema : string, default None Name of SQL schema in database to write to (if database flavor supports this). If None, use default schema (default).