From f9fbe81f9c2e32378b5c3eb3d00e0f689f8b1fdb Mon Sep 17 00:00:00 2001 From: Jeff Reback Date: Sat, 15 Dec 2018 15:49:12 -0500 Subject: [PATCH 1/4] DOC: whatsnew 0.24.0 corrections & edits & remove some warnings --- doc/source/api.rst | 66 ++++++- doc/source/basics.rst | 6 +- doc/source/conf.py | 2 +- doc/source/io.rst | 14 +- doc/source/whatsnew/v0.24.0.rst | 325 ++++++++++++++++--------------- pandas/core/indexes/accessors.py | 12 +- 6 files changed, 257 insertions(+), 168 deletions(-) diff --git a/doc/source/api.rst b/doc/source/api.rst index d9e3cb177511a..6387a34a3d21f 100644 --- a/doc/source/api.rst +++ b/doc/source/api.rst @@ -113,6 +113,7 @@ HDFStore: PyTables (HDF5) HDFStore.select HDFStore.info HDFStore.keys + HDFStore.groups HDFStore.walk Feather @@ -611,6 +612,16 @@ These can be accessed like ``Series.dt.``. Series.dt.month_name Series.dt.day_name +**Period Properties** + +.. autosummary:: + :toctree: generated/ + :template: autosummary/accessor_attribute.rst + + Series.dt.qyear + Series.dt.start_time + Series.dt.end_time + **Timedelta Properties** .. autosummary:: @@ -1648,7 +1659,14 @@ Categorical Components CategoricalIndex.set_categories CategoricalIndex.as_ordered CategoricalIndex.as_unordered + +Modifying and Computations +~~~~~~~~~~~~~~~~~~~~~~~~~~ +.. autosummary:: + :toctree: generated/ + CategoricalIndex.map + CategoricalIndex.equals .. _api.intervalindex: @@ -1741,6 +1759,7 @@ MultiIndex Components MultiIndex.swaplevel MultiIndex.reorder_levels MultiIndex.remove_unused_levels + MultiIndex.reindex MultiIndex.unique MultiIndex Selecting @@ -1750,10 +1769,23 @@ MultiIndex Selecting :toctree: generated/ MultiIndex.get_loc + MultiIndex.get_loc_level MultiIndex.get_indexer MultiIndex.get_level_values -.. _api.datetimeindex: +Modifying and Computations +~~~~~~~~~~~~~~~~~~~~~~~~~~ +.. autosummary:: + :toctree: generated/ + + MultiIndex.copy + MultiIndex.drop_duplicates + MultiIndex.duplicated + MultiIndex.equals + MultiIndex.repeat + MultiIndex.where + + .. _api.datetimeindex: DatetimeIndex ------------- @@ -1834,6 +1866,16 @@ Conversion DatetimeIndex.to_pydatetime DatetimeIndex.to_series DatetimeIndex.to_frame + DatetimeIndex.shift + +Sorting +~~~~~~~ +.. autosummary:: + :toctree: generated/ + + DatetimeIndex.argsort + DatetimeIndex.searchsorted + DatetimeIndex.sort_values TimedeltaIndex -------------- @@ -1869,6 +1911,15 @@ Conversion TimedeltaIndex.ceil TimedeltaIndex.to_frame +Sorting +~~~~~~~ +.. autosummary:: + :toctree: generated/ + + TimedeltaIndex.argsort + TimedeltaIndex.searchsorted + TimedeltaIndex.sort_values + .. currentmodule:: pandas PeriodIndex @@ -1914,6 +1965,17 @@ Methods PeriodIndex.asfreq PeriodIndex.strftime PeriodIndex.to_timestamp + PeriodIndex.shift + PeriodIndex.unique + +Sorting +~~~~~~~ +.. autosummary:: + :toctree: generated/ + + PeriodIndex.argsort + PeriodIndex.searchsorted + PeriodIndex.sort_values Scalars ------- @@ -2292,6 +2354,7 @@ Function application :toctree: generated/ GroupBy.apply + GroupBy.agg GroupBy.aggregate GroupBy.transform GroupBy.pipe @@ -2336,7 +2399,6 @@ application to columns of a specific data type. .. autosummary:: :toctree: generated/ - DataFrameGroupBy.agg DataFrameGroupBy.all DataFrameGroupBy.any DataFrameGroupBy.bfill diff --git a/doc/source/basics.rst b/doc/source/basics.rst index dfb8764b5c8e8..a188a5716f7bc 100644 --- a/doc/source/basics.rst +++ b/doc/source/basics.rst @@ -88,7 +88,7 @@ may involve copying data and coercing values. Getting the "raw data" inside a :class:`DataFrame` is possibly a bit more complex. When your ``DataFrame`` only has a single data type for all the -columns, :atr:`DataFrame.to_numpy` will return the underlying data: +columns, :attr:`DataFrame.to_numpy` will return the underlying data: .. ipython:: python @@ -1931,7 +1931,7 @@ Categorical :class:`CategoricalDtype` (none) :class:`Categor period (time spans) :class:`PeriodDtype` :class:`Period` :class:`arrays.PeriodArray` :ref:`timeseries.periods` sparse :class:`SparseDtype` (none) :class:`arrays.SparseArray` :ref:`sparse` intervals :class:`IntervalDtype` :class:`Interval` :class:`arrays.IntervalArray` :ref:`advanced.intervalindex` -nullable integer :clsas:`Int64Dtype`, ... (none) :class:`arrays.IntegerArray` :ref:`integer_na` +nullable integer :class:`Int64Dtype`, ... (none) :class:`arrays.IntegerArray` :ref:`integer_na` =================== ========================= ================== ============================= ============================= Pandas uses the ``object`` dtype for storing strings. @@ -2324,4 +2324,4 @@ All NumPy dtypes are subclasses of ``numpy.generic``: .. note:: Pandas also defines the types ``category``, and ``datetime64[ns, tz]``, which are not integrated into the normal - NumPy hierarchy and won't show up with the above function. \ No newline at end of file + NumPy hierarchy and won't show up with the above function. diff --git a/doc/source/conf.py b/doc/source/conf.py index 067d568dea8aa..2d1369499dfda 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -369,7 +369,7 @@ intersphinx_mapping = { 'statsmodels': ('http://www.statsmodels.org/devel/', None), - 'matplotlib': ('http://matplotlib.org/', None), + 'matplotlib': ('https://matplotlib.org/', None), 'pandas-gbq': ('https://pandas-gbq.readthedocs.io/en/latest/', None), 'python': ('https://docs.python.org/3/', None), 'numpy': ('https://docs.scipy.org/doc/numpy/', None), diff --git a/doc/source/io.rst b/doc/source/io.rst index f9da5ee6d6737..035e8087b416c 100644 --- a/doc/source/io.rst +++ b/doc/source/io.rst @@ -1863,7 +1863,9 @@ Writing to a file, with a date index and a date column: dfj2['bools'] = True dfj2.index = pd.date_range('20130101', periods=5) dfj2.to_json('test.json') - open('test.json').read() + + with open('test.json') as fh: + print(fh.read()) Fallback Behavior +++++++++++++++++ @@ -2321,6 +2323,11 @@ indicate missing values and the subsequent read cannot distinguish the intent. new_df = pd.read_json('test.json', orient='table') print(new_df.index.name) +.. ipython:: python + :suppress: + + os.remove('test.json') + .. _Table Schema: https://specs.frictionlessdata.io/json-table-schema/ HTML @@ -4766,6 +4773,11 @@ this file into a ``DataFrame``. Passing ``index=True`` will *always* write the index, even if that's not the underlying engine's default behavior. +.. ipython:: python + :suppress: + + os.remove('test.parquet') + Partitioning Parquet files '''''''''''''''''''''''''' diff --git a/doc/source/whatsnew/v0.24.0.rst b/doc/source/whatsnew/v0.24.0.rst index db1758199be0d..14423c0e418cf 100644 --- a/doc/source/whatsnew/v0.24.0.rst +++ b/doc/source/whatsnew/v0.24.0.rst @@ -1,11 +1,13 @@ .. _whatsnew_0240: -What's New in 0.24.0 (Month XX, 2018) -------------------------------------- +What's New in 0.24.0 (January XX, 2019) +--------------------------------------- .. warning:: - Starting January 1, 2019, pandas feature releases will support Python 3 only. + The 0.24.x series of releases will be the last to support Python 2. Future feature + releases will support Python 3 only. + See :ref:`install.dropping-27` for more. {{ header }} @@ -26,7 +28,7 @@ New features dataframe's indexes from the resulting Parquet file. (:issue:`20768`) - :meth:`DataFrame.corr` and :meth:`Series.corr` now accept a callable for generic calculation methods of correlation, e.g. histogram intersection (:issue:`22684`) - :func:`DataFrame.to_string` now accepts ``decimal`` as an argument, allowing the user to specify which decimal separator should be used in the output. (:issue:`23614`) -- :func:`DataFrame.read_feather` now accepts ``columns`` as an argument, allowing the user to specify which columns should be read. (:issue:`24025`) +- :func:`read_feather` now accepts ``columns`` as an argument, allowing the user to specify which columns should be read. (:issue:`24025`) - :func:`DataFrame.to_html` now accepts ``render_links`` as an argument, allowing the user to generate HTML with links to any URLs that appear in the DataFrame. See the :ref:`section on writing HTML ` in the IO docs for example usage. (:issue:`2679`) @@ -36,7 +38,7 @@ Accessing the values in a Series or Index ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ :attr:`Series.array` and :attr:`Index.array` have been added for extracting the array backing a -``Series`` or ``Index``. +``Series`` or ``Index``. (:issue:`19954`, :issue:`23623`) .. ipython:: python @@ -74,7 +76,7 @@ as ``.values``). We haven't removed or deprecated :attr:`Series.values` or :attr:`DataFrame.values`, but we recommend and using ``.array`` or ``.to_numpy()`` instead. -See :ref:`basics.dtypes` and :ref:`dsintro.attrs` for more. +See :ref:`Dtypes ` and :ref:`Attributes and Underlying Data ` for more. .. _whatsnew_0240.enhancements.extension_array_operators: @@ -180,7 +182,7 @@ value. (:issue:`17054`) """) -Previous Behavior: +*Previous Behavior*: .. code-block:: ipython @@ -189,7 +191,7 @@ Previous Behavior: [ A B C 0 1 2 NaN] -Current Behavior: +*New Behavior*: .. ipython:: python @@ -201,7 +203,7 @@ Current Behavior: Storing Interval and Period Data in Series and DataFrame ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Interval and Period data may now be stored in a ``Series`` or ``DataFrame``, in addition to an +:class:`Interval` and :class:`Period` data may now be stored in a :class:`Series` or :class:`DataFrame`, in addition to an :class:`IntervalIndex` and :class:`PeriodIndex` like previously (:issue:`19453`, :issue:`22862`). .. ipython:: python @@ -210,7 +212,7 @@ Interval and Period data may now be stored in a ``Series`` or ``DataFrame``, in ser ser.dtype -And for periods: +For periods: .. ipython:: python @@ -223,7 +225,7 @@ this should result in better performance when storing an array of intervals or p in a :class:`Series` or column of a :class:`DataFrame`. Use :attr:`Series.array` to extract the underlying array of intervals or periods -from the ``Series``:: +from the ``Series``: .. ipython:: python @@ -236,16 +238,17 @@ from the ``Series``:: a NumPy array of objects for Interval and Period data. We recommend using :attr:`Series.array` when you need the array of data stored in the ``Series``, and :meth:`Series.to_numpy` when you know you need a NumPy array. - See :ref:`basics.dtypes` and :ref:`dsintro.attrs` for more. -.. _whatsnew_0240.enhancements.styler_pipe: + See :ref:`Dtypes ` and :ref:`Attributes and Underlying Data ` + for more. + New ``Styler.pipe()`` method ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The :class:`~pandas.io.formats.style.Styler` class has gained a -:meth:`~pandas.io.formats.style.Styler.pipe` method (:issue:`23229`). This provides a +:meth:`~pandas.io.formats.style.Styler.pipe` method. This provides a convenient way to apply users' predefined styling functions, and can help reduce -"boilerplate" when using DataFrame styling functionality repeatedly within a notebook. +"boilerplate" when using DataFrame styling functionality repeatedly within a notebook. (:issue:`23229`) .. ipython:: python @@ -258,7 +261,7 @@ convenient way to apply users' predefined styling functions, and can help reduce df.style.pipe(format_and_align).set_caption('Summary of results.') Similar methods already exist for other classes in pandas, including :meth:`DataFrame.pipe`, -:meth:`Groupby.pipe`, and :meth:`Resampler.pipe`. +:meth:`pandas.core.groupby.GroupBy.pipe`, and :meth:`pandas.core.resample.Resampler.pipe`. .. _whatsnew_0240.enhancements.join_with_two_multiindexes: @@ -266,7 +269,7 @@ Similar methods already exist for other classes in pandas, including :meth:`Data Joining with two multi-indexes ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -:func:`Datafame.merge` and :func:`Dataframe.join` can now be used to join multi-indexed ``Dataframe`` instances on the overlaping index levels (:issue:`6360`) +:func:`DataFrame.merge` and :func:`DataFrame.join` can now be used to join multi-indexed ``Dataframe`` instances on the overlaping index levels (:issue:`6360`) See the :ref:`Merge, join, and concatenate ` documentation section. @@ -318,7 +321,7 @@ Example: df df.rename_axis(index={'CD': 'New'}) -See the :ref:`advanced docs on renaming` for more details. +See the :ref:`Advanced documentation on renaming` for more details. .. _whatsnew_0240.enhancements.other: @@ -328,11 +331,11 @@ Other Enhancements - :func:`to_datetime` now supports the ``%Z`` and ``%z`` directive when passed into ``format`` (:issue:`13486`) - :func:`Series.mode` and :func:`DataFrame.mode` now support the ``dropna`` parameter which can be used to specify whether ``NaN``/``NaT`` values should be considered (:issue:`17534`) -- :func:`to_csv` now supports ``compression`` keyword when a file handle is passed. (:issue:`21227`) +- :func:`DataFrame.to_csv` and :func:`Series.to_csv` now support the ``compression`` keyword when a file handle is passed. (:issue:`21227`) - :meth:`Index.droplevel` is now implemented also for flat indexes, for compatibility with :class:`MultiIndex` (:issue:`21115`) - :meth:`Series.droplevel` and :meth:`DataFrame.droplevel` are now implemented (:issue:`20342`) - Added support for reading from/writing to Google Cloud Storage via the ``gcsfs`` library (:issue:`19454`, :issue:`23094`) -- :func:`to_gbq` and :func:`read_gbq` signature and documentation updated to +- :func:`DataFrame.to_gbq` and :func:`read_gbq` signature and documentation updated to reflect changes from the `Pandas-GBQ library version 0.8.0 `__. Adds a ``credentials`` argument, which enables the use of any kind of @@ -348,26 +351,26 @@ Other Enhancements - :meth:`DataFrame.to_sql` now supports writing ``TIMESTAMP WITH TIME ZONE`` types for supported databases. For databases that don't support timezones, datetime data will be stored as timezone unaware local timestamps. See the :ref:`io.sql_datetime_data` for implications (:issue:`9086`). - :func:`to_timedelta` now supports iso-formated timedelta strings (:issue:`21877`) - :class:`Series` and :class:`DataFrame` now support :class:`Iterable` in constructor (:issue:`2193`) -- :class:`DatetimeIndex` gained :attr:`DatetimeIndex.timetz` attribute. Returns local time with timezone information. (:issue:`21358`) -- :meth:`round`, :meth:`ceil`, and meth:`floor` for :class:`DatetimeIndex` and :class:`Timestamp` now support an ``ambiguous`` argument for handling datetimes that are rounded to ambiguous times (:issue:`18946`) -- :meth:`round`, :meth:`ceil`, and meth:`floor` for :class:`DatetimeIndex` and :class:`Timestamp` now support a ``nonexistent`` argument for handling datetimes that are rounded to nonexistent times. See :ref:`timeseries.timezone_nonexistent` (:issue:`22647`) -- :class:`Resampler` now is iterable like :class:`GroupBy` (:issue:`15314`). -- :meth:`Series.resample` and :meth:`DataFrame.resample` have gained the :meth:`Resampler.quantile` (:issue:`15023`). +- :class:`DatetimeIndex` has gained the :attr:`DatetimeIndex.timetz` attribute. This returns the local time with timezone information. (:issue:`21358`) +- :meth:`Timestamp.round`, :meth:`Timestamp.ceil`, and meth:`Timestamp.floor` for :class:`DatetimeIndex` and :class:`Timestamp` now support an ``ambiguous`` argument for handling datetimes that are rounded to ambiguous times (:issue:`18946`) +- :meth:`Timestamp.round`, :meth:`Timestamp.ceil`, and meth:`Timestamp.floor` for :class:`DatetimeIndex` and :class:`Timestamp` now support a ``nonexistent`` argument for handling datetimes that are rounded to nonexistent times. See :ref:`timeseries.timezone_nonexistent` (:issue:`22647`) +- :class:`pandas.core.resample.Resampler` now is iterable like :class:`pandas.core.groupby.GroupBy` (:issue:`15314`). +- :meth:`Series.resample` and :meth:`DataFrame.resample` have gained the :meth:`pandas.core.resample.Resampler.quantile` (:issue:`15023`). - :meth:`DataFrame.resample` and :meth:`Series.resample` with a :class:`PeriodIndex` will now respect the ``base`` argument in the same fashion as with a :class:`DatetimeIndex`. (:issue:`23882`) -- :meth:`pandas.core.dtypes.is_list_like` has gained a keyword ``allow_sets`` which is ``True`` by default; if ``False``, +- :meth:`pandas.api.types.is_list_like` has gained a keyword ``allow_sets`` which is ``True`` by default; if ``False``, all instances of ``set`` will not be considered "list-like" anymore (:issue:`23061`) - :meth:`Index.to_frame` now supports overriding column name(s) (:issue:`22580`). - New attribute :attr:`__git_version__` will return git commit sha of current build (:issue:`21295`). - Compatibility with Matplotlib 3.0 (:issue:`22790`). - Added :meth:`Interval.overlaps`, :meth:`IntervalArray.overlaps`, and :meth:`IntervalIndex.overlaps` for determining overlaps between interval-like objects (:issue:`21998`) -- :func:`read_fwf` now accepts keyword `infer_nrows` (:issue:`15138`). +- :func:`read_fwf` now accepts keyword ``infer_nrows`` (:issue:`15138`). - :func:`~DataFrame.to_parquet` now supports writing a ``DataFrame`` as a directory of parquet files partitioned by a subset of the columns when ``engine = 'pyarrow'`` (:issue:`23283`) - :meth:`Timestamp.tz_localize`, :meth:`DatetimeIndex.tz_localize`, and :meth:`Series.tz_localize` have gained the ``nonexistent`` argument for alternative handling of nonexistent times. See :ref:`timeseries.timezone_nonexistent` (:issue:`8917`) - :meth:`Index.difference` now has an optional ``sort`` parameter to specify whether the results should be sorted if possible (:issue:`17839`) - :meth:`read_excel()` now accepts ``usecols`` as a list of column names or callable (:issue:`18273`) - :meth:`MultiIndex.to_flat_index` has been added to flatten multiple levels into a single-level :class:`Index` object. -- :meth:`DataFrame.to_stata` and :class:` pandas.io.stata.StataWriter117` can write mixed sting columns to Stata strl format (:issue:`23633`) -- :meth:`DataFrame.between_time` and :meth:`DataFrame.at_time` have gained the an ``axis`` parameter (:issue: `8839`) +- :meth:`DataFrame.to_stata` and :class:`pandas.io.stata.StataWriter117` can write mixed sting columns to Stata strl format (:issue:`23633`) +- :meth:`DataFrame.between_time` and :meth:`DataFrame.at_time` have gained the an ``axis`` parameter (:issue:`8839`) - :class:`IntervalIndex` has gained the :attr:`~IntervalIndex.is_overlapping` attribute to indicate if the ``IntervalIndex`` contains any overlapping intervals (:issue:`23309`) .. _whatsnew_0240.api_breaking: @@ -376,17 +379,17 @@ Backwards incompatible API changes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - A newly constructed empty :class:`DataFrame` with integer as the ``dtype`` will now only be cast to ``float64`` if ``index`` is specified (:issue:`22858`) -- :meth:`Series.str.cat` will now raise if `others` is a `set` (:issue:`23009`) +- :meth:`Series.str.cat` will now raise if ``others`` is a ``set`` (:issue:`23009`) - Passing scalar values to :class:`DatetimeIndex` or :class:`TimedeltaIndex` will now raise ``TypeError`` instead of ``ValueError`` (:issue:`23539`) - ``max_rows`` and ``max_cols`` parameters removed from :class:`HTMLFormatter` since truncation is handled by :class:`DataFrameFormatter` (:issue:`23818`) -- :meth:`read_csv` will now raise a ``ValueError`` if a column with missing values is declared as having dtype ``bool`` (:issue:`20591`) +- :func:`read_csv` will now raise a ``ValueError`` if a column with missing values is declared as having dtype ``bool`` (:issue:`20591`) - The column order of the resultant :class:`DataFrame` from :meth:`MultiIndex.to_frame` is now guaranteed to match the :attr:`MultiIndex.names` order. (:issue:`22420`) - :func:`pd.offsets.generate_range` argument ``time_rule`` has been removed; use ``offset`` instead (:issue:`24157`) -Percentage change on groupby changes -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Percentage change on groupby +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Fixed a bug where calling :func:`SeriesGroupBy.pct_change` or :func:`DataFrameGroupBy.pct_change` would previously work across groups when calculating the percent change, where it now correctly works per group (:issue:`21200`, :issue:`21235`). +Fixed a bug where calling :func:`pancas.core.groupby.SeriesGroupBy.pct_change` or :func:`pandas.core.groupby.DataFrameGroupBy.pct_change` would previously work across groups when calculating the percent change, where it now correctly works per group (:issue:`21200`, :issue:`21235`). .. ipython:: python @@ -444,8 +447,8 @@ If installed, we now require: | pytest (dev) | 3.6 | | +-----------------+-----------------+----------+ -Additionally we no longer depend on `feather-format` for feather based storage -and replaced it with references to `pyarrow` (:issue:`21639` and :issue:`23053`). +Additionally we no longer depend on ``feather-format`` for feather based storage +and replaced it with references to ``pyarrow`` (:issue:`21639` and :issue:`23053`). .. _whatsnew_0240.api_breaking.csv_line_terminator: @@ -457,7 +460,7 @@ for the default line terminator (:issue:`20353`). This change only affects when running on Windows, where ``'\r\n'`` was used for line terminator even when ``'\n'`` was passed in ``line_terminator``. -Previous Behavior on Windows: +*Previous Behavior* on Windows: .. code-block:: ipython @@ -483,54 +486,51 @@ Previous Behavior on Windows: Out[5]: b'string_with_lf,string_with_crlf\n"a\nbc","a\r\nbc"\n' -New Behavior on Windows: +*New Behavior* on Windows: -- By passing ``line_terminator`` explicitly, line terminator is set to that character. -- The value of ``line_terminator`` only affects the line terminator of CSV, - so it does not change the value inside the data. +Passing ``line_terminator`` explicitly, set thes ``line terminator`` to that character. - .. code-block:: ipython +.. code-block:: ipython - In [1]: data = pd.DataFrame({"string_with_lf": ["a\nbc"], - ...: "string_with_crlf": ["a\r\nbc"]}) + In [1]: data = pd.DataFrame({"string_with_lf": ["a\nbc"], + ...: "string_with_crlf": ["a\r\nbc"]}) - In [2]: data.to_csv("test.csv", index=False, line_terminator='\n') + In [2]: data.to_csv("test.csv", index=False, line_terminator='\n') - In [3]: with open("test.csv", mode='rb') as f: - ...: print(f.read()) - Out[3]: b'string_with_lf,string_with_crlf\n"a\nbc","a\r\nbc"\n' + In [3]: with open("test.csv", mode='rb') as f: + ...: print(f.read()) + Out[3]: b'string_with_lf,string_with_crlf\n"a\nbc","a\r\nbc"\n' -- On Windows, the value of ``os.linesep`` is ``'\r\n'``, - so if ``line_terminator`` is not set, ``'\r\n'`` is used for line terminator. -- Again, it does not affect the value inside the data. +On Windows, the value of ``os.linesep`` is ``'\r\n'``, so if ``line_terminator`` is not +set, ``'\r\n'`` is used for line terminator. - .. code-block:: ipython +.. code-block:: ipython - In [1]: data = pd.DataFrame({"string_with_lf": ["a\nbc"], - ...: "string_with_crlf": ["a\r\nbc"]}) + In [1]: data = pd.DataFrame({"string_with_lf": ["a\nbc"], + ...: "string_with_crlf": ["a\r\nbc"]}) - In [2]: data.to_csv("test.csv", index=False) + In [2]: data.to_csv("test.csv", index=False) - In [3]: with open("test.csv", mode='rb') as f: - ...: print(f.read()) - Out[3]: b'string_with_lf,string_with_crlf\r\n"a\nbc","a\r\nbc"\r\n' + In [3]: with open("test.csv", mode='rb') as f: + ...: print(f.read()) + Out[3]: b'string_with_lf,string_with_crlf\r\n"a\nbc","a\r\nbc"\r\n' -- For files objects, specifying ``newline`` is not sufficient to set the line terminator. - You must pass in the ``line_terminator`` explicitly, even in this case. +For file objects, specifying ``newline`` is not sufficient to set the line terminator. +You must pass in the ``line_terminator`` explicitly, even in this case. - .. code-block:: ipython +.. code-block:: ipython - In [1]: data = pd.DataFrame({"string_with_lf": ["a\nbc"], - ...: "string_with_crlf": ["a\r\nbc"]}) + In [1]: data = pd.DataFrame({"string_with_lf": ["a\nbc"], + ...: "string_with_crlf": ["a\r\nbc"]}) - In [2]: with open("test2.csv", mode='w', newline='\n') as f: - ...: data.to_csv(f, index=False) + In [2]: with open("test2.csv", mode='w', newline='\n') as f: + ...: data.to_csv(f, index=False) - In [3]: with open("test2.csv", mode='rb') as f: - ...: print(f.read()) - Out[3]: b'string_with_lf,string_with_crlf\r\n"a\nbc","a\r\nbc"\r\n' + In [3]: with open("test2.csv", mode='rb') as f: + ...: print(f.read()) + Out[3]: b'string_with_lf,string_with_crlf\r\n"a\nbc","a\r\nbc"\r\n' .. _whatsnew_0240.api.timezone_offset_parsing: @@ -559,7 +559,7 @@ UTC offset (:issue:`17697`, :issue:`11736`, :issue:`22457`) In [4]: pd.to_datetime(["2015-11-18 15:30:00+05:30", "2015-11-18 16:30:00+06:30"]) Out[4]: DatetimeIndex(['2015-11-18 10:00:00', '2015-11-18 10:00:00'], dtype='datetime64[ns]', freq=None) -*Current Behavior*: +*New Behavior*: .. ipython:: python @@ -618,6 +618,8 @@ respected absolute time instead (i.e. ``Day(n)`` and acted identically to ``Time In [4]: ts + pd.tseries.frequencies.to_offset('D') Out[4]: Timestamp('2016-10-30 23:00:00+0200', tz='Europe/Helsinki') +*New Behavior*: + :class:`CalendarDay` and associated frequency alias ``'CD'`` are now available and respect calendar day arithmetic while :class:`Day` and frequency alias ``'D'`` will now respect absolute time (:issue:`22274`, :issue:`20596`, :issue:`16980`, :issue:`8774`) @@ -641,7 +643,7 @@ to '23:59:59.999999999' when calling :attr:`Series.dt.end_time`, :attr:`Period.e :attr:`PeriodIndex.end_time`, :func:`Period.to_timestamp()` with ``how='end'``, or :func:`PeriodIndex.to_timestamp()` with ``how='end'`` (:issue:`17157`) -Previous Behavior: +*Previous Behavior*: .. code-block:: ipython @@ -654,7 +656,7 @@ Previous Behavior: In [5]: p.end_time Out[5]: Timestamp(2017-01-01 23:59:59.999999999) -Current Behavior: +*New Behavior*: Calling :attr:`Series.dt.end_time` will now result in a time of '23:59:59.999999999' as is the case with :attr:`Period.end_time`, for example @@ -678,9 +680,9 @@ is now an extension array (:issue:`21978`, :issue:`19056`, :issue:`22835`). To conform to this interface and for consistency with the rest of pandas, some API breaking changes were made: -- ``SparseArray`` is no longer a subclass of :class:`numpy.ndarray`. To convert a SparseArray to a NumPy array, use :meth:`numpy.asarray`. +- ``SparseArray`` is no longer a subclass of :class:`numpy.ndarray`. To convert a ``SparseArray`` to a NumPy array, use :func:`numpy.asarray`. - ``SparseArray.dtype`` and ``SparseSeries.dtype`` are now instances of :class:`SparseDtype`, rather than ``np.dtype``. Access the underlying dtype with ``SparseDtype.subtype``. -- :meth:`numpy.asarray(sparse_array)` now returns a dense array with all the values, not just the non-fill-value values (:issue:`14167`) +- ``numpy.asarray(sparse_array)`` now returns a dense array with all the values, not just the non-fill-value values (:issue:`14167`) - ``SparseArray.take`` now matches the API of :meth:`pandas.api.extensions.ExtensionArray.take` (:issue:`19506`): * The default value of ``allow_fill`` has changed from ``False`` to ``True``. @@ -698,7 +700,7 @@ Some new warnings are issued for operations that require or are likely to materi - A :class:`errors.PerformanceWarning` is issued when using fillna with a ``method``, as a dense array is constructed to create the filled array. Filling with a ``value`` is the efficient way to fill a sparse array. - A :class:`errors.PerformanceWarning` is now issued when concatenating sparse Series with differing fill values. The fill value from the first sparse array continues to be used. -In addition to these API breaking changes, many :ref:`performance improvements and bug fixes have been made `. +In addition to these API breaking changes, many :ref:`Performance Improvements and Bug Fixes have been made `. Finally, a ``Series.sparse`` accessor was added to provide sparse-specific methods like :meth:`Series.sparse.from_coo`. @@ -800,7 +802,7 @@ where addition could fail to be monotone or associative. (:issue:`21427`) In [7]: ts + tic + tic + tic == ts + (tic + tic + tic) Out[7]: False -*Current Behavior*: +*New Behavior*: .. ipython:: python @@ -826,7 +828,7 @@ instead of an integer (:issue:`21314`) april = pd.Period('April 2018') june - april -Previous Behavior: +*Previous Behavior*: .. code-block:: ipython @@ -845,7 +847,7 @@ an ``Index`` of ``DateOffset`` objects instead of an ``Int64Index`` pi = pd.period_range('June 2018', freq='M', periods=3) pi - pi[0] -Previous Behavior: +*Previous Behavior*: .. code-block:: ipython @@ -866,12 +868,17 @@ all-``NaT``. This is for compatibility with ``TimedeltaIndex`` and ``Series`` behavior (:issue:`22163`) .. ipython:: python - :okexcept: df = pd.DataFrame([pd.Timedelta(days=1)]) - df - np.nan + df -Previous Behavior: +.. code-block:: ipython + + In [2]: df - np.nan + ... + TypeError: unsupported operand type(s) for -: 'TimedeltaIndex' and 'float' + +*Previous Behavior*: .. code-block:: ipython @@ -898,7 +905,7 @@ The affected cases are: - a list or tuple with length matching the number of rows in the :class:`DataFrame` will now raise ``ValueError`` instead of operating column-by-column (:issue:`22880`. - a list or tuple with length matching the number of columns in the :class:`DataFrame` will now operate row-by-row instead of raising ``ValueError`` (:issue:`22880`). -Previous Behavior: +*Previous Behavior*: .. code-block:: ipython @@ -940,13 +947,14 @@ Previous Behavior: ... ValueError: Unable to coerce to Series, length must be 2: given 3 -*Current Behavior*: +*New Behavior*: .. ipython:: python :okexcept: arr = np.arange(6).reshape(3, 2) df = pd.DataFrame(arr) + df .. ipython:: python @@ -960,13 +968,16 @@ Previous Behavior: df == (1, 2) df + (1, 2) -.. ipython:: python - :okexcept: +.. code-block:: ipython # Comparison operations and arithmetic opeartions both raise ValueError. - df == (1, 2, 3) - df + (1, 2, 3) + In [6]: df == (1, 2, 3) + ... + ValueError: Unable to coerce to Series, length must be 2: given 3 + In [7]: df + (1, 2, 3) + ... + ValueError: Unable to coerce to Series, length must be 2: given 3 .. _whatsnew_0240.api.dataframe_arithmetic_broadcasting: @@ -977,7 +988,7 @@ DataFrame Arithmetic Operations Broadcasting Changes ``np.ndarray`` objects now broadcast in the same way as ``np.ndarray`` broadcast. (:issue:`23000`) -Previous Behavior: +*Previous Behavior*: .. code-block:: ipython @@ -990,7 +1001,7 @@ Previous Behavior: ... ValueError: Unable to coerce to DataFrame, shape must be (3, 2): given (3, 1) -*Current Behavior*: +*New Behavior*: .. ipython:: python @@ -1009,7 +1020,7 @@ Previous Behavior: ExtensionType Changes ^^^^^^^^^^^^^^^^^^^^^ -**:class:`pandas.api.extensions.ExtensionDtype` Equality and Hashability** +:class:`pandas.api.extensions.ExtensionDtype` **Equality and Hashability** Pandas now requires that extension dtypes be hashable. The base class implements a default ``__eq__`` and ``__hash__``. If you have a parametrized dtype, you should @@ -1040,7 +1051,7 @@ update the ``ExtensionDtype._metadata`` tuple to match the signature of your - :meth:`DataFrame.stack` no longer converts to object dtype for DataFrames where each column has the same extension dtype. The output Series will have the same dtype as the columns (:issue:`23077`). - :meth:`Series.unstack` and :meth:`DataFrame.unstack` no longer convert extension arrays to object-dtype ndarrays. Each column in the output ``DataFrame`` will now have the same dtype as the input (:issue:`23077`). - Bug when grouping :meth:`Dataframe.groupby()` and aggregating on ``ExtensionArray`` it was not returning the actual ``ExtensionArray`` dtype (:issue:`23227`). -- A default repr for :class:`ExtensionArray` is now provided (:issue:`23601`). +- A default repr for :class:`pandas.api.extensions.ExtensionArray` is now provided (:issue:`23601`). .. _whatsnew_0240.api.incompatibilities: @@ -1050,7 +1061,7 @@ Series and Index Data-Dtype Incompatibilities ``Series`` and ``Index`` constructors now raise when the data is incompatible with a passed ``dtype=`` (:issue:`15832`) -Previous Behavior: +*Previous Behavior*: .. code-block:: ipython @@ -1059,7 +1070,7 @@ Previous Behavior: 0 18446744073709551615 dtype: uint64 -Current Behavior: +*New Behavior*: .. code-block:: ipython @@ -1076,7 +1087,7 @@ Crosstab Preserves Dtypes :func:`crosstab` will preserve now dtypes in some cases that previously would cast from integer dtype to floating dtype (:issue:`22019`) -Previous Behavior: +*Previous Behavior*: .. code-block:: ipython @@ -1089,7 +1100,7 @@ Previous Behavior: 1 0.5 0.0 2 0.5 1.0 -Current Behavior: +*New Behavior*: .. code-block:: ipython @@ -1153,7 +1164,7 @@ Deprecations - :meth:`Series.compress` is deprecated. Use ``Series[condition]`` instead (:issue:`18262`) - The signature of :meth:`Series.to_csv` has been uniformed to that of :meth:`DataFrame.to_csv`: the name of the first argument is now ``path_or_buf``, the order of subsequent arguments has changed, the ``header`` argument now defaults to ``True``. (:issue:`19715`) - :meth:`Categorical.from_codes` has deprecated providing float values for the ``codes`` argument. (:issue:`21767`) -- :func:`pandas.read_table` is deprecated. Instead, use :func:`pandas.read_csv` passing ``sep='\t'`` if necessary (:issue:`21948`) +- :func:`pandas.read_table` is deprecated. Instead, use :func:`read_csv` passing ``sep='\t'`` if necessary (:issue:`21948`) - :meth:`Series.str.cat` has deprecated using arbitrary list-likes *within* list-likes. A list-like container may still contain many ``Series``, ``Index`` or 1-dimensional ``np.ndarray``, or alternatively, only scalar values. (:issue:`21950`) - :meth:`FrozenNDArray.searchsorted` has deprecated the ``v`` parameter in favor of ``value`` (:issue:`14645`) @@ -1163,8 +1174,7 @@ Deprecations - The class ``FrozenNDArray`` has been deprecated. When unpickling, ``FrozenNDArray`` will be unpickled to ``np.ndarray`` once this class is removed (:issue:`9031`) - The methods :meth:`DataFrame.update` and :meth:`Panel.update` have deprecated the ``raise_conflict=False|True`` keyword in favor of ``errors='ignore'|'raise'`` (:issue:`23585`) - The methods :meth:`Series.str.partition` and :meth:`Series.str.rpartition` have deprecated the ``pat`` keyword in favor of ``sep`` (:issue:`22676`) -- Deprecated the `nthreads` keyword of :func:`pandas.read_feather` in favor of - `use_threads` to reflect the changes in pyarrow 0.11.0. (:issue:`23053`) +- Deprecated the ``nthreads`` keyword of :func:`pandas.read_feather` in favor of ``use_threads`` to reflect the changes in ``pyarrow>=0.11.0``. (:issue:`23053`) - :meth:`ExtensionArray._formatting_values` is deprecated. Use :attr:`ExtensionArray._formatter` instead. (:issue:`23601`) - :func:`pandas.read_excel` has deprecated accepting ``usecols`` as an integer. Please pass in a list of ints from 0 to ``usecols`` inclusive instead (:issue:`23527`) - Constructing a :class:`TimedeltaIndex` from data with ``datetime64``-dtyped data is deprecated, will raise ``TypeError`` in a future version (:issue:`23539`) @@ -1172,10 +1182,10 @@ Deprecations - The ``keep_tz=False`` option (the default) of the ``keep_tz`` keyword of :meth:`DatetimeIndex.to_series` is deprecated (:issue:`17832`). - Timezone converting a tz-aware ``datetime.datetime`` or :class:`Timestamp` with :class:`Timestamp` and the ``tz`` argument is now deprecated. Instead, use :meth:`Timestamp.tz_convert` (:issue:`23579`) -- :func:`pandas.types.is_period` is deprecated in favor of `pandas.types.is_period_dtype` (:issue:`23917`) -- :func:`pandas.types.is_datetimetz` is deprecated in favor of `pandas.types.is_datetime64tz` (:issue:`23917`) +- :func:`pandas.api.types.is_period` is deprecated in favor of `pandas.api.types.is_period_dtype` (:issue:`23917`) +- :func:`pandas.api.types.is_datetimetz` is deprecated in favor of `pandas.api.types.is_datetime64tz` (:issue:`23917`) - Creating a :class:`TimedeltaIndex` or :class:`DatetimeIndex` by passing range arguments `start`, `end`, and `periods` is deprecated in favor of :func:`timedelta_range` and :func:`date_range` (:issue:`23919`) -- Passing a string alias like ``'datetime64[ns, UTC]'`` as the `unit` parameter to :class:`DatetimeTZDtype` is deprecated. Use :class:`DatetimeTZDtype.construct_from_string` instead (:issue:`23990`). +- Passing a string alias like ``'datetime64[ns, UTC]'`` as the ``unit`` parameter to :class:`DatetimeTZDtype` is deprecated. Use :class:`DatetimeTZDtype.construct_from_string` instead (:issue:`23990`). - In :meth:`Series.where` with Categorical data, providing an ``other`` that is not present in the categories is deprecated. Convert the categorical to a different dtype or add the ``other`` to the categories first (:issue:`24077`). - :meth:`Series.clip_lower`, :meth:`Series.clip_upper`, :meth:`DataFrame.clip_lower` and :meth:`DataFrame.clip_upper` are deprecated and will be removed in a future version. Use ``Series.clip(lower=threshold)``, ``Series.clip(upper=threshold)`` and the equivalent ``DataFrame`` methods (:issue:`24203`) @@ -1192,7 +1202,7 @@ the object's ``freq`` attribute. The result of subtraction of :class:`Period` objects will be agnostic of the multiplier of the objects' ``freq`` attribute (:issue:`21939`, :issue:`23878`). -Previous Behavior: +*Previous Behavior*: .. code-block:: ipython @@ -1212,7 +1222,7 @@ Previous Behavior: In [10]: dti + pd.Index([1, 2]) Out[10]: DatetimeIndex(['2001-01-08', '2001-01-22'], dtype='datetime64[ns]', freq=None) -Current Behavior: +*New Behavior*: .. ipython:: python :okwarning: @@ -1247,15 +1257,15 @@ Removal of prior version deprecations/changes - Removal of the previously deprecated ``as_indexer`` keyword completely from ``str.match()`` (:issue:`22356`, :issue:`6581`) - The modules ``pandas.types``, ``pandas.computation``, and ``pandas.util.decorators`` have been removed (:issue:`16157`, :issue:`16250`) - Removed the ``pandas.formats.style`` shim for :class:`pandas.io.formats.style.Styler` (:issue:`16059`) -- :func:`pandas.pnow`, :func:`pandas.match`, :func:`pandas.groupby`, :func:`pd.get_store`, ``pd.Expr``, and ``pd.Term`` have been removed (:issue:`15538`, :issue:`15940`) +- ``pandas.pnow``, ``pandas.match``, ``pandas.groupby``, ``pd.get_store``, ``pd.Expr``, and ``pd.Term`` have been removed (:issue:`15538`, :issue:`15940`) - :meth:`Categorical.searchsorted` and :meth:`Series.searchsorted` have renamed the ``v`` argument to ``value`` (:issue:`14645`) - ``pandas.parser``, ``pandas.lib``, and ``pandas.tslib`` have been removed (:issue:`15537`) - :meth:`TimedeltaIndex.searchsorted`, :meth:`DatetimeIndex.searchsorted`, and :meth:`PeriodIndex.searchsorted` have renamed the ``key`` argument to ``value`` (:issue:`14645`) -- :meth:`DataFrame.consolidate` and :meth:`Series.consolidate` have been removed (:issue:`15501`) +- ``DataFrame.consolidate`` and ``Series.consolidate`` have been removed (:issue:`15501`) - Removal of the previously deprecated module ``pandas.json`` (:issue:`19944`) - The module ``pandas.tools`` has been removed (:issue:`15358`, :issue:`16005`) - :meth:`SparseArray.get_values` and :meth:`SparseArray.to_dense` have dropped the ``fill`` parameter (:issue:`14686`) -- :meth:`DataFrame.sortlevel` and :meth:`Series.sortlevel` have been removed (:issue:`15099`) +- ``DataFrame.sortlevel`` and ``Series.sortlevel`` have been removed (:issue:`15099`) - :meth:`SparseSeries.to_dense` has dropped the ``sparse_only`` parameter (:issue:`14686`) - :meth:`DataFrame.astype` and :meth:`Series.astype` have renamed the ``raise_on_error`` argument to ``errors`` (:issue:`14967`) - ``is_sequence``, ``is_any_int_dtype``, and ``is_floating_dtype`` have been removed from ``pandas.api.types`` (:issue:`16163`, :issue:`16189`) @@ -1279,16 +1289,16 @@ Performance Improvements (i.e. ``x in cat``-style checks are much faster). :meth:`CategoricalIndex.contains` is likewise much faster (:issue:`21369`, :issue:`21508`) - Improved performance of :meth:`HDFStore.groups` (and dependent functions like - :meth:`~HDFStore.keys`. (i.e. ``x in store`` checks are much faster) + :meth:`HDFStore.keys`. (i.e. ``x in store`` checks are much faster) (:issue:`21372`) - Improved the performance of :func:`pandas.get_dummies` with ``sparse=True`` (:issue:`21997`) - Improved performance of :func:`IndexEngine.get_indexer_non_unique` for sorted, non-unique indexes (:issue:`9466`) - Improved performance of :func:`PeriodIndex.unique` (:issue:`23083`) -- Improved performance of :func:`pd.concat` for `Series` objects (:issue:`23404`) +- Improved performance of :func:`concat` for `Series` objects (:issue:`23404`) - Improved performance of :meth:`DatetimeIndex.normalize` and :meth:`Timestamp.normalize` for timezone naive or UTC datetimes (:issue:`23634`) - Improved performance of :meth:`DatetimeIndex.tz_localize` and various ``DatetimeIndex`` attributes with dateutil UTC timezone (:issue:`23772`) -- Fixed a performance regression on Windows with Python 3.7 of :func:`pd.read_csv` (:issue:`23516`) -- Improved performance of :class:`Categorical` constructor for `Series` objects (:issue:`23814`) +- Fixed a performance regression on Windows with Python 3.7 of :func:`read_csv` (:issue:`23516`) +- Improved performance of :class:`Categorical` constructor for ``Series`` objects (:issue:`23814`) - Improved performance of :meth:`~DataFrame.where` for Categorical data (:issue:`24077`) .. _whatsnew_0240.docs: @@ -1296,8 +1306,6 @@ Performance Improvements Documentation Changes ~~~~~~~~~~~~~~~~~~~~~ -- -- - .. _whatsnew_0240.bug_fixes: @@ -1313,8 +1321,8 @@ Categorical - Bug when indexing with a boolean-valued ``Categorical``. Now a boolean-valued ``Categorical`` is treated as a boolean mask (:issue:`22665`) - Constructing a :class:`CategoricalIndex` with empty values and boolean categories was raising a ``ValueError`` after a change to dtype coercion (:issue:`22702`). - Bug in :meth:`Categorical.take` with a user-provided ``fill_value`` not encoding the ``fill_value``, which could result in a ``ValueError``, incorrect results, or a segmentation fault (:issue:`23296`). -- In meth:`Series.unstack`, specifying a ``fill_value`` not present in the categories now raises a ``TypeError`` rather than ignoring the ``fill_value`` (:issue:`23284`) -- Bug when resampling :meth:`Dataframe.resample()` and aggregating on categorical data, the categorical dtype was getting lost. (:issue:`23227`) +- In :meth:`Series.unstack`, specifying a ``fill_value`` not present in the categories now raises a ``TypeError`` rather than ignoring the ``fill_value`` (:issue:`23284`) +- Bug when resampling :meth:`DataFrame.resample()` and aggregating on categorical data, the categorical dtype was getting lost. (:issue:`23227`) - Bug in many methods of the ``.str``-accessor, which always failed on calling the ``CategoricalIndex.str`` constructor (:issue:`23555`, :issue:`23556`) - Bug in :meth:`Series.where` losing the categorical dtype for categorical data (:issue:`24077`) @@ -1370,7 +1378,7 @@ Timedelta - Fixed bug where subtracting :class:`Timedelta` from an object-dtyped array would raise ``TypeError`` (:issue:`21980`) - Fixed bug in adding a :class:`DataFrame` with all-`timedelta64[ns]` dtypes to a :class:`DataFrame` with all-integer dtypes returning incorrect results instead of raising ``TypeError`` (:issue:`22696`) - Bug in :class:`TimedeltaIndex` where adding a timezone-aware datetime scalar incorrectly returned a timezone-naive :class:`DatetimeIndex` (:issue:`23215`) -- Bug in :class:`TimedeltaIndex` where adding ``np.timedelta64('NaT')`` incorrectly returned an all-`NaT` :class:`DatetimeIndex` instead of an all-`NaT` :class:`TimedeltaIndex` (:issue:`23215`) +- Bug in :class:`TimedeltaIndex` where adding ``np.timedelta64('NaT')`` incorrectly returned an all-``NaT`` :class:`DatetimeIndex` instead of an all-``NaT`` :class:`TimedeltaIndex` (:issue:`23215`) - Bug in :class:`Timedelta` and :func:`to_timedelta()` have inconsistencies in supported unit string (:issue:`21762`) - Bug in :class:`TimedeltaIndex` division where dividing by another :class:`TimedeltaIndex` raised ``TypeError`` instead of returning a :class:`Float64Index` (:issue:`23829`, :issue:`22631`) - Bug in :class:`TimedeltaIndex` comparison operations where comparing against non-``Timedelta``-like objects would raise ``TypeError`` instead of returning all-``False`` for ``__eq__`` and all-``True`` for ``__ne__`` (:issue:`24056`) @@ -1398,7 +1406,7 @@ Timezones - Bug when indexing a :class:`Series` with a DST transition (:issue:`21846`) - Bug in :meth:`DataFrame.resample` and :meth:`Series.resample` where an ``AmbiguousTimeError`` or ``NonExistentTimeError`` would raise if a timezone aware timeseries ended on a DST transition (:issue:`19375`, :issue:`10117`) - Bug in :meth:`DataFrame.drop` and :meth:`Series.drop` when specifying a tz-aware Timestamp key to drop from a :class:`DatetimeIndex` with a DST transition (:issue:`21761`) -- Bug in :class:`DatetimeIndex` constructor where :class:`NaT` and ``dateutil.tz.tzlocal`` would raise an ``OutOfBoundsDatetime`` error (:issue:`23807`) +- Bug in :class:`DatetimeIndex` constructor where ``NaT`` and ``dateutil.tz.tzlocal`` would raise an ``OutOfBoundsDatetime`` error (:issue:`23807`) - Bug in :meth:`DatetimeIndex.tz_localize` and :meth:`Timestamp.tz_localize` with ``dateutil.tz.tzlocal`` near a DST transition that would return an incorrectly localized datetime (:issue:`23807`) - Bug in :class:`Timestamp` constructor where a ``dateutil.tz.tzutc`` timezone passed with a ``datetime.datetime`` argument would be converted to a ``pytz.UTC`` timezone (:issue:`23807`) @@ -1429,6 +1437,13 @@ Numeric - Bug in :meth:`Series.rank` and :meth:`DataFrame.rank` when ``pct=True`` and more than 2:sup:`24` rows are present resulted in percentages greater than 1.0 (:issue:`18271`) - Calls such as :meth:`DataFrame.round` with a non-unique :meth:`CategoricalIndex` now return expected data. Previously, data would be improperly duplicated (:issue:`21809`). - Added ``log10`` to the list of supported functions in :meth:`DataFrame.eval` (:issue:`24139`) +- Logical operations ``&, |, ^`` between :class:`Series` and :class:`Index` will no longer raise ``ValueError`` (:issue:`22092`) +- Checking PEP 3141 numbers in :func:`~pandas.api.types.is_scalar` function returns ``True`` (:issue:`22903`) + + Conversion +^^^^^^^^^^ + +- Bug in :meth:`DataFrame.combine_first` in which column types were unexpectedly converted to float (:issue:`20699`) Strings ^^^^^^^ @@ -1451,7 +1466,7 @@ Indexing ^^^^^^^^ - The traceback from a ``KeyError`` when asking ``.loc`` for a single missing label is now shorter and more clear (:issue:`21557`) -- :class:`PeriodIndex` now emits a ``KeyError`` when a malformed string is looked up, which is consistent with the behavior of :class:`DateTimeIndex` (:issue:`22803`) +- :class:`PeriodIndex` now emits a ``KeyError`` when a malformed string is looked up, which is consistent with the behavior of :class:`DatetimeIndex` (:issue:`22803`) - When ``.ix`` is asked for a missing integer label in a :class:`MultiIndex` with a first level of integer type, it now raises a ``KeyError``, consistently with the case of a flat :class:`Int64Index`, rather than falling back to positional indexing (:issue:`21593`) - Bug in :meth:`DatetimeIndex.reindex` when reindexing a tz-naive and tz-aware :class:`DatetimeIndex` (:issue:`8306`) - Bug in :meth:`Series.reindex` when reindexing an empty series with a ``datetime64[ns, tz]`` dtype (:issue:`20869`) @@ -1464,8 +1479,8 @@ Indexing - ``Float64Index.get_loc`` now raises ``KeyError`` when boolean key passed. (:issue:`19087`) - Bug in :meth:`DataFrame.loc` when indexing with an :class:`IntervalIndex` (:issue:`19977`) - :class:`Index` no longer mangles ``None``, ``NaN`` and ``NaT``, i.e. they are treated as three different keys. However, for numeric Index all three are still coerced to a ``NaN`` (:issue:`22332`) -- Bug in `scalar in Index` if scalar is a float while the ``Index`` is of integer dtype (:issue:`22085`) -- Bug in `MultiIndex.set_levels` when levels value is not subscriptable (:issue:`23273`) +- Bug in ``scalar in Index`` if scalar is a float while the ``Index`` is of integer dtype (:issue:`22085`) +- Bug in :func:`MultiIndex.set_levels` when levels value is not subscriptable (:issue:`23273`) - Bug where setting a timedelta column by ``Index`` causes it to be casted to double, and therefore lose precision (:issue:`23511`) - Bug in :func:`Index.union` and :func:`Index.intersection` where name of the ``Index`` of the result was not computed correctly for certain cases (:issue:`9943`, :issue:`9862`) - Bug in :class:`Index` slicing with boolean :class:`Index` may raise ``TypeError`` (:issue:`22533`) @@ -1477,8 +1492,8 @@ Missing - Bug in :func:`DataFrame.fillna` where a ``ValueError`` would raise when one column contained a ``datetime64[ns, tz]`` dtype (:issue:`15522`) - Bug in :func:`Series.hasnans` that could be incorrectly cached and return incorrect answers if null elements are introduced after an initial call (:issue:`19700`) -- :func:`Series.isin` now treats all NaN-floats as equal also for `np.object`-dtype. This behavior is consistent with the behavior for float64 (:issue:`22119`) -- :func:`unique` no longer mangles NaN-floats and the ``NaT``-object for `np.object`-dtype, i.e. ``NaT`` is no longer coerced to a NaN-value and is treated as a different entity. (:issue:`22295`) +- :func:`Series.isin` now treats all NaN-floats as equal also for ``np.object``-dtype. This behavior is consistent with the behavior for float64 (:issue:`22119`) +- :func:`unique` no longer mangles NaN-floats and the ``NaT``-object for ``np.object``-dtype, i.e. ``NaT`` is no longer coerced to a NaN-value and is treated as a different entity. (:issue:`22295`) MultiIndex @@ -1486,7 +1501,7 @@ MultiIndex - Removed compatibility for :class:`MultiIndex` pickles prior to version 0.8.0; compatibility with :class:`MultiIndex` pickles from version 0.13 forward is maintained (:issue:`21654`) - :meth:`MultiIndex.get_loc_level` (and as a consequence, ``.loc`` on a ``Series`` or ``DataFrame`` with a :class:`MultiIndex` index) will now raise a ``KeyError``, rather than returning an empty ``slice``, if asked a label which is present in the ``levels`` but is unused (:issue:`22221`) -- :cls:`MultiIndex` has gained the :meth:`MultiIndex.from_frame`, it allows constructing a :cls:`MultiIndex` object from a :cls:`DataFrame` (:issue:`22420`) +- :class:`MultiIndex` has gained the :meth:`MultiIndex.from_frame`, it allows constructing a :class:`MultiIndex` object from a :class:`DataFrame` (:issue:`22420`) - Fix ``TypeError`` in Python 3 when creating :class:`MultiIndex` in which some levels have mixed types, e.g. when some labels are tuples (:issue:`15457`) I/O @@ -1501,14 +1516,14 @@ Proper handling of `np.NaN` in a string data-typed column with the Python engine There was bug in :func:`read_excel` and :func:`read_csv` with the Python engine, where missing values turned to ``'nan'`` with ``dtype=str`` and ``na_filter=True``. Now, these missing values are converted to the string -missing indicator, ``np.nan``. (:issue `20377`) +missing indicator, ``np.nan``. (:issue:`20377`) .. ipython:: python :suppress: from pandas.compat import StringIO -Previous Behavior: +*Previous Behavior*: .. code-block:: ipython @@ -1518,7 +1533,7 @@ Previous Behavior: Out[7]: 'nan' -Current Behavior: +*New Behavior*: .. ipython:: python @@ -1529,8 +1544,8 @@ Current Behavior: Notice how we now instead output ``np.nan`` itself instead of a stringified form of it. - Bug in :func:`read_csv` in which a column specified with ``CategoricalDtype`` of boolean categories was not being correctly coerced from string values to booleans (:issue:`20498`) -- Bug in :meth:`to_sql` when writing timezone aware data (``datetime64[ns, tz]`` dtype) would raise a ``TypeError`` (:issue:`9086`) -- Bug in :meth:`to_sql` where a naive DatetimeIndex would be written as ``TIMESTAMP WITH TIMEZONE`` type in supported databases, e.g. PostgreSQL (:issue:`23510`) +- Bug in :meth:`DataFrame.to_sql` when writing timezone aware data (``datetime64[ns, tz]`` dtype) would raise a ``TypeError`` (:issue:`9086`) +- Bug in :meth:`DataFrame.to_sql` where a naive :class:`DatetimeIndex` would be written as ``TIMESTAMP WITH TIMEZONE`` type in supported databases, e.g. PostgreSQL (:issue:`23510`) - Bug in :meth:`read_excel()` when ``parse_cols`` is specified with an empty dataset (:issue:`9208`) - :func:`read_html()` no longer ignores all-whitespace ```` within ```` when considering the ``skiprows`` and ``header`` arguments. Previously, users had to decrease their ``header`` and ``skiprows`` values on such tables to work around the issue. (:issue:`21641`) - :func:`read_excel()` will correctly show the deprecation warning for previously deprecated ``sheetname`` (:issue:`17994`) @@ -1546,13 +1561,13 @@ Notice how we now instead output ``np.nan`` itself instead of a stringified form - Bug in :func:`DataFrame.to_string()` that broke column alignment when ``index=False`` and width of first column's values is greater than the width of first column's header (:issue:`16839`, :issue:`13032`) - Bug in :func:`DataFrame.to_string()` that caused representations of :class:`DataFrame` to not take up the whole window (:issue:`22984`) - Bug in :func:`DataFrame.to_csv` where a single level MultiIndex incorrectly wrote a tuple. Now just the value of the index is written (:issue:`19589`). -- :func:`HDFStore` will raise ``ValueError`` when the ``format`` kwarg is passed to the constructor (:issue:`13291`) +- :class:`HDFStore` will raise ``ValueError`` when the ``format`` kwarg is passed to the constructor (:issue:`13291`) - Bug in :meth:`HDFStore.append` when appending a :class:`DataFrame` with an empty string column and ``min_itemsize`` < 8 (:issue:`12242`) - Bug in :func:`read_csv()` in which memory leaks occurred in the C engine when parsing ``NaN`` values due to insufficient cleanup on completion or error (:issue:`21353`) - Bug in :func:`read_csv()` in which incorrect error messages were being raised when ``skipfooter`` was passed in along with ``nrows``, ``iterator``, or ``chunksize`` (:issue:`23711`) -- Bug in :meth:`read_csv()` in which :class:`MultiIndex` index names were being improperly handled in the cases when they were not provided (:issue:`23484`) -- Bug in :meth:`read_csv()` in which unnecessary warnings were being raised when the dialect's values conflicted with the default arguments (:issue:`23761`) -- Bug in :meth:`read_html()` in which the error message was not displaying the valid flavors when an invalid one was provided (:issue:`23549`) +- Bug in :func:`read_csv()` in which :class:`MultiIndex` index names were being improperly handled in the cases when they were not provided (:issue:`23484`) +- Bug in :func:`read_csv()` in which unnecessary warnings were being raised when the dialect's values conflicted with the default arguments (:issue:`23761`) +- Bug in :func:`read_html()` in which the error message was not displaying the valid flavors when an invalid one was provided (:issue:`23549`) - Bug in :meth:`read_excel()` in which extraneous header names were extracted, even though none were specified (:issue:`11733`) - Bug in :meth:`read_excel()` in which column names were not being properly converted to string sometimes in Python 2.x (:issue:`23874`) - Bug in :meth:`read_excel()` in which ``index_col=None`` was not being respected and parsing index columns anyway (:issue:`18792`, :issue:`20480`) @@ -1560,7 +1575,7 @@ Notice how we now instead output ``np.nan`` itself instead of a stringified form - Bug in :meth:`DataFrame.to_dict` when the resulting dict contains non-Python scalars in the case of numeric data (:issue:`23753`) - :func:`DataFrame.to_string()`, :func:`DataFrame.to_html()`, :func:`DataFrame.to_latex()` will correctly format output when a string is passed as the ``float_format`` argument (:issue:`21625`, :issue:`22270`) - Bug in :func:`read_csv` that caused it to raise ``OverflowError`` when trying to use 'inf' as ``na_value`` with integer index column (:issue:`17128`) -- Bug in :func:`json_normalize` that caused it to raise ``TypeError`` when two consecutive elements of ``record_path`` are dicts (:issue:`22706`) +- Bug in :func:`pandas.io.json.json_normalize` that caused it to raise ``TypeError`` when two consecutive elements of ``record_path`` are dicts (:issue:`22706`) Plotting ^^^^^^^^ @@ -1568,27 +1583,27 @@ Plotting - Bug in :func:`DataFrame.plot.scatter` and :func:`DataFrame.plot.hexbin` caused x-axis label and ticklabels to disappear when colorbar was on in IPython inline backend (:issue:`10611`, :issue:`10678`, and :issue:`20455`) - Bug in plotting a Series with datetimes using :func:`matplotlib.axes.Axes.scatter` (:issue:`22039`) -Groupby/Resample/Rolling + Groupby/Resample/Rolling ^^^^^^^^^^^^^^^^^^^^^^^^ - Bug in :func:`pandas.core.groupby.GroupBy.first` and :func:`pandas.core.groupby.GroupBy.last` with ``as_index=False`` leading to the loss of timezone information (:issue:`15884`) -- Bug in :meth:`DatetimeIndex.resample` when downsampling across a DST boundary (:issue:`8531`) -- Bug in date anchoring for :meth:`DatetimeIndex.resample` with offset :class:`Day` when n > 1 (:issue:`24127`) +- Bug in :meth:`DateFrame.resample` when downsampling across a DST boundary (:issue:`8531`) +- Bug in date anchoring for :meth:`DateFrame.resample` with offset :class:`Day` when n > 1 (:issue:`24127`) - Bug where ``ValueError`` is wrongly raised when calling :func:`~pandas.core.groupby.SeriesGroupBy.count` method of a ``SeriesGroupBy`` when the grouping variable only contains NaNs and numpy version < 1.13 (:issue:`21956`). -- Multiple bugs in :func:`pandas.core.Rolling.min` with ``closed='left'`` and a +- Multiple bugs in :func:`pandas.core.window.Rolling.min` with ``closed='left'`` and a datetime-like index leading to incorrect results and also segfault. (:issue:`21704`) -- Bug in :meth:`Resampler.apply` when passing postiional arguments to applied func (:issue:`14615`). +- Bug in :meth:`pandas.core.resample.Resampler.apply` when passing postiional arguments to applied func (:issue:`14615`). - Bug in :meth:`Series.resample` when passing ``numpy.timedelta64`` to ``loffset`` kwarg (:issue:`7687`). -- Bug in :meth:`Resampler.asfreq` when frequency of ``TimedeltaIndex`` is a subperiod of a new frequency (:issue:`13022`). -- Bug in :meth:`SeriesGroupBy.mean` when values were integral but could not fit inside of int64, overflowing instead. (:issue:`22487`) -- :func:`RollingGroupby.agg` and :func:`ExpandingGroupby.agg` now support multiple aggregation functions as parameters (:issue:`15072`) +- Bug in :meth:`pandas.core.resample.Resampler.asfreq` when frequency of ``TimedeltaIndex`` is a subperiod of a new frequency (:issue:`13022`). +- Bug in :meth:`pandas.core.groupby.SeriesGroupBy.mean` when values were integral but could not fit inside of int64, overflowing instead. (:issue:`22487`) +- :func:`pandas.core.groupby.RollingGroupby.agg` and :func:`pandas.core.groupby.ExpandingGroupby.agg` now support multiple aggregation functions as parameters (:issue:`15072`) - Bug in :meth:`DataFrame.resample` and :meth:`Series.resample` when resampling by a weekly offset (``'W'``) across a DST transition (:issue:`9119`, :issue:`21459`) - Bug in :meth:`DataFrame.expanding` in which the ``axis`` argument was not being respected during aggregations (:issue:`23372`) -- Bug in :meth:`pandas.core.groupby.DataFrameGroupBy.transform` which caused missing values when the input function can accept a :class:`DataFrame` but renames it (:issue:`23455`). +- Bug in :meth:`pandas.core.groupby.GroupBy.transform` which caused missing values when the input function can accept a :class:`DataFrame` but renames it (:issue:`23455`). - Bug in :func:`pandas.core.groupby.GroupBy.nth` where column order was not always preserved (:issue:`20760`) -- Bug in :meth:`pandas.core.groupby.DataFrameGroupBy.rank` with ``method='dense'`` and ``pct=True`` when a group has only one member would raise a ``ZeroDivisionError`` (:issue:`23666`). -- Calling :meth:`DataFrameGroupBy.rank` and :meth:`SeriesGroupBy.rank` with empty groups and ``pct=True`` was raising a ``ZeroDivisionError`` due to `c1068d9 `_ (:issue:`22519`) +- Bug in :meth:`pandas.core.groupby.GroupBy.rank` with ``method='dense'`` and ``pct=True`` when a group has only one member would raise a ``ZeroDivisionError`` (:issue:`23666`). +- Calling :meth:`pancas.core.groupby.GroupBy.rank` with empty groups and ``pct=True`` was raising a ``ZeroDivisionError`` (:issue:`22519`) - Bug in :meth:`DataFrame.resample` when resampling ``NaT`` in ``TimeDeltaIndex`` (:issue:`13223`). Reshaping @@ -1604,7 +1619,7 @@ Reshaping - :func:`pandas.core.groupby.GroupBy.rank` now raises a ``ValueError`` when an invalid value is passed for argument ``na_option`` (:issue:`22124`) - Bug in :func:`get_dummies` with Unicode attributes in Python 2 (:issue:`22084`) - Bug in :meth:`DataFrame.replace` raises ``RecursionError`` when replacing empty lists (:issue:`22083`) -- Bug in :meth:`Series.replace` and meth:`DataFrame.replace` when dict is used as the ``to_replace`` value and one key in the dict is is another key's value, the results were inconsistent between using integer key and using string key (:issue:`20656`) +- Bug in :meth:`Series.replace` and :meth:`DataFrame.replace` when dict is used as the ``to_replace`` value and one key in the dict is is another key's value, the results were inconsistent between using integer key and using string key (:issue:`20656`) - Bug in :meth:`DataFrame.drop_duplicates` for empty ``DataFrame`` which incorrectly raises an error (:issue:`20516`) - Bug in :func:`pandas.wide_to_long` when a string is passed to the stubnames argument and a column name is a substring of that stubname (:issue:`22468`) - Bug in :func:`merge` when merging ``datetime64[ns, tz]`` data that contained a DST transition (:issue:`18885`) @@ -1614,10 +1629,13 @@ Reshaping - Bug in :meth:`DataFrame.nsmallest` and :meth:`DataFrame.nlargest` for dataframes that have a :class:`MultiIndex` for columns (:issue:`23033`). - Bug in :func:`pandas.melt` when passing column names that are not present in ``DataFrame`` (:issue:`23575`) - Bug in :meth:`DataFrame.append` with a :class:`Series` with a dateutil timezone would raise a ``TypeError`` (:issue:`23682`) -- Bug in ``Series`` construction when passing no data and ``dtype=str`` (:issue:`22477`) +- Bug in :class:`Series` construction when passing no data and ``dtype=str`` (:issue:`22477`) - Bug in :func:`cut` with ``bins`` as an overlapping ``IntervalIndex`` where multiple bins were returned per item instead of raising a ``ValueError`` (:issue:`23980`) - Bug in :func:`pandas.concat` when joining ``Series`` datetimetz with ``Series`` category would lose timezone (:issue:`23816`) - Bug in :meth:`DataFrame.join` when joining on partial MultiIndex would drop names (:issue:`20452`). +- :meth:`DataFrame.nlargest` and :meth:`DataFrame.nsmallest` now returns the correct n values when keep != 'all' also when tied on the first columns (:issue:`22752`) +- Constructing a DataFrame with an index argument that wasn't already an instance of :class:`~pandas.core.Index` was broken (:issue:`22227`). +- Bug in :class:`DataFrame` prevented list subclasses to be used to construction (:issue:`21226`) .. _whatsnew_0240.bug_fixes.sparse: @@ -1635,27 +1653,24 @@ Sparse - Bug in :meth:`SparseArray.nonzero` and :meth:`SparseDataFrame.dropna` returning shifted/incorrect results (:issue:`21172`) - Bug in :meth:`DataFrame.apply` where dtypes would lose sparseness (:issue:`23744`) +Style +^^^^^ + +- :meth:`~pandas.io.formats.style.Styler.background_gradient` now takes a ``text_color_threshold`` parameter to automatically lighten the text color based on the luminance of the background color. This improves readability with dark background colors without the need to limit the background colormap range. (:issue:`21258`) +- Require at least 0.28.2 version of ``cython`` to support read-only memoryviews (:issue:`21688`) +- :meth:`~pandas.io.formats.style.Styler.background_gradient` now also supports tablewise application (in addition to rowwise and columnwise) with ``axis=None`` (:issue:`15204`) +- :meth:`~pandas.io.formats.style.Styler.bar` now also supports tablewise application (in addition to rowwise and columnwise) with ``axis=None`` and setting clipping range with ``vmin`` and ``vmax`` (:issue:`21548` and :issue:`21526`). ``NaN`` values are also handled properly. + Build Changes ^^^^^^^^^^^^^ - Building pandas for development now requires ``cython >= 0.28.2`` (:issue:`21688`) - Testing pandas now requires ``hypothesis>=3.58``. You can find `the Hypothesis docs here `_, and a pandas-specific introduction :ref:`in the contributing guide `. (:issue:`22280`) -- Other ^^^^^ -- :meth:`~pandas.io.formats.style.Styler.background_gradient` now takes a ``text_color_threshold`` parameter to automatically lighten the text color based on the luminance of the background color. This improves readability with dark background colors without the need to limit the background colormap range. (:issue:`21258`) -- Require at least 0.28.2 version of ``cython`` to support read-only memoryviews (:issue:`21688`) -- :meth:`~pandas.io.formats.style.Styler.background_gradient` now also supports tablewise application (in addition to rowwise and columnwise) with ``axis=None`` (:issue:`15204`) -- :meth:`DataFrame.nlargest` and :meth:`DataFrame.nsmallest` now returns the correct n values when keep != 'all' also when tied on the first columns (:issue:`22752`) -- :meth:`~pandas.io.formats.style.Styler.bar` now also supports tablewise application (in addition to rowwise and columnwise) with ``axis=None`` and setting clipping range with ``vmin`` and ``vmax`` (:issue:`21548` and :issue:`21526`). ``NaN`` values are also handled properly. -- Logical operations ``&, |, ^`` between :class:`Series` and :class:`Index` will no longer raise ``ValueError`` (:issue:`22092`) -- Checking PEP 3141 numbers in :func:`~pandas.api.types.is_scalar` function returns ``True`` (:issue:`22903`) -- Bug in :meth:`DataFrame.combine_first` in which column types were unexpectedly converted to float (:issue:`20699`) - Bug where C variables were declared with external linkage causing import errors if certain other C libraries were imported before Pandas. (:issue:`24113`) -- Constructing a DataFrame with an index argument that wasn't already an instance of :class:`~pandas.core.Index` was broken in `4efb39f `_ (:issue:`22227`). -- Bug in :func:`to_object_array` prevented list subclasses to be used to create :class:`DataFrame` (:issue:`21226`) .. _whatsnew_0.24.0.contributors: diff --git a/pandas/core/indexes/accessors.py b/pandas/core/indexes/accessors.py index ecc96ca1ecc94..670c4a2d8a414 100644 --- a/pandas/core/indexes/accessors.py +++ b/pandas/core/indexes/accessors.py @@ -289,7 +289,8 @@ class PeriodProperties(Properties): """ -class CombinedDatetimelikeProperties(DatetimeProperties, TimedeltaProperties): +class CombinedDatetimelikeProperties(DatetimeProperties, + TimedeltaProperties, PeriodProperties): def __new__(cls, data): # CombinedDatetimelikeProperties isn't really instantiated. Instead @@ -315,11 +316,10 @@ def __new__(cls, data): return DatetimeProperties(data, orig) elif is_timedelta64_dtype(data.dtype): return TimedeltaProperties(data, orig) - else: - if is_period_arraylike(data): - return PeriodProperties(data, orig) - if is_datetime_arraylike(data): - return DatetimeProperties(data, orig) + elif is_period_arraylike(data): + return PeriodProperties(data, orig) + elif is_datetime_arraylike(data): + return DatetimeProperties(data, orig) except Exception: pass # we raise an attribute error anyway From d7c7db00bf5f10d9c8a87fc68a459a936196a875 Mon Sep 17 00:00:00 2001 From: Jeff Reback Date: Sat, 15 Dec 2018 20:12:18 -0500 Subject: [PATCH 2/4] review --- doc/source/api.rst | 2 +- doc/source/whatsnew/v0.24.0.rst | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/source/api.rst b/doc/source/api.rst index 6387a34a3d21f..ff20eb258f91d 100644 --- a/doc/source/api.rst +++ b/doc/source/api.rst @@ -1785,7 +1785,7 @@ Modifying and Computations MultiIndex.repeat MultiIndex.where - .. _api.datetimeindex: +.. _api.datetimeindex: DatetimeIndex ------------- diff --git a/doc/source/whatsnew/v0.24.0.rst b/doc/source/whatsnew/v0.24.0.rst index 14423c0e418cf..4caadf0b65dd8 100644 --- a/doc/source/whatsnew/v0.24.0.rst +++ b/doc/source/whatsnew/v0.24.0.rst @@ -1583,7 +1583,7 @@ Plotting - Bug in :func:`DataFrame.plot.scatter` and :func:`DataFrame.plot.hexbin` caused x-axis label and ticklabels to disappear when colorbar was on in IPython inline backend (:issue:`10611`, :issue:`10678`, and :issue:`20455`) - Bug in plotting a Series with datetimes using :func:`matplotlib.axes.Axes.scatter` (:issue:`22039`) - Groupby/Resample/Rolling +Groupby/Resample/Rolling ^^^^^^^^^^^^^^^^^^^^^^^^ - Bug in :func:`pandas.core.groupby.GroupBy.first` and :func:`pandas.core.groupby.GroupBy.last` with ``as_index=False`` leading to the loss of timezone information (:issue:`15884`) @@ -1657,7 +1657,6 @@ Style ^^^^^ - :meth:`~pandas.io.formats.style.Styler.background_gradient` now takes a ``text_color_threshold`` parameter to automatically lighten the text color based on the luminance of the background color. This improves readability with dark background colors without the need to limit the background colormap range. (:issue:`21258`) -- Require at least 0.28.2 version of ``cython`` to support read-only memoryviews (:issue:`21688`) - :meth:`~pandas.io.formats.style.Styler.background_gradient` now also supports tablewise application (in addition to rowwise and columnwise) with ``axis=None`` (:issue:`15204`) - :meth:`~pandas.io.formats.style.Styler.bar` now also supports tablewise application (in addition to rowwise and columnwise) with ``axis=None`` and setting clipping range with ``vmin`` and ``vmax`` (:issue:`21548` and :issue:`21526`). ``NaN`` values are also handled properly. @@ -1671,6 +1670,7 @@ Other ^^^^^ - Bug where C variables were declared with external linkage causing import errors if certain other C libraries were imported before Pandas. (:issue:`24113`) +- Require at least 0.28.2 version of ``cython`` to support read-only memoryviews (:issue:`21688`) .. _whatsnew_0.24.0.contributors: From 26bd1d5589c47ee26f05c1f1755e8cff5391b3e2 Mon Sep 17 00:00:00 2001 From: Jeff Reback Date: Sun, 16 Dec 2018 16:06:10 -0500 Subject: [PATCH 3/4] revert api refernces --- doc/source/api.rst | 44 --------------------------------- doc/source/whatsnew/v0.24.0.rst | 8 +++--- 2 files changed, 4 insertions(+), 48 deletions(-) diff --git a/doc/source/api.rst b/doc/source/api.rst index ff20eb258f91d..d80c73d4a7c1c 100644 --- a/doc/source/api.rst +++ b/doc/source/api.rst @@ -1759,8 +1759,6 @@ MultiIndex Components MultiIndex.swaplevel MultiIndex.reorder_levels MultiIndex.remove_unused_levels - MultiIndex.reindex - MultiIndex.unique MultiIndex Selecting ~~~~~~~~~~~~~~~~~~~~ @@ -1773,18 +1771,6 @@ MultiIndex Selecting MultiIndex.get_indexer MultiIndex.get_level_values -Modifying and Computations -~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. autosummary:: - :toctree: generated/ - - MultiIndex.copy - MultiIndex.drop_duplicates - MultiIndex.duplicated - MultiIndex.equals - MultiIndex.repeat - MultiIndex.where - .. _api.datetimeindex: DatetimeIndex @@ -1866,16 +1852,6 @@ Conversion DatetimeIndex.to_pydatetime DatetimeIndex.to_series DatetimeIndex.to_frame - DatetimeIndex.shift - -Sorting -~~~~~~~ -.. autosummary:: - :toctree: generated/ - - DatetimeIndex.argsort - DatetimeIndex.searchsorted - DatetimeIndex.sort_values TimedeltaIndex -------------- @@ -1911,15 +1887,6 @@ Conversion TimedeltaIndex.ceil TimedeltaIndex.to_frame -Sorting -~~~~~~~ -.. autosummary:: - :toctree: generated/ - - TimedeltaIndex.argsort - TimedeltaIndex.searchsorted - TimedeltaIndex.sort_values - .. currentmodule:: pandas PeriodIndex @@ -1965,17 +1932,6 @@ Methods PeriodIndex.asfreq PeriodIndex.strftime PeriodIndex.to_timestamp - PeriodIndex.shift - PeriodIndex.unique - -Sorting -~~~~~~~ -.. autosummary:: - :toctree: generated/ - - PeriodIndex.argsort - PeriodIndex.searchsorted - PeriodIndex.sort_values Scalars ------- diff --git a/doc/source/whatsnew/v0.24.0.rst b/doc/source/whatsnew/v0.24.0.rst index 4caadf0b65dd8..b9f5be2583f17 100644 --- a/doc/source/whatsnew/v0.24.0.rst +++ b/doc/source/whatsnew/v0.24.0.rst @@ -1260,7 +1260,7 @@ Removal of prior version deprecations/changes - ``pandas.pnow``, ``pandas.match``, ``pandas.groupby``, ``pd.get_store``, ``pd.Expr``, and ``pd.Term`` have been removed (:issue:`15538`, :issue:`15940`) - :meth:`Categorical.searchsorted` and :meth:`Series.searchsorted` have renamed the ``v`` argument to ``value`` (:issue:`14645`) - ``pandas.parser``, ``pandas.lib``, and ``pandas.tslib`` have been removed (:issue:`15537`) -- :meth:`TimedeltaIndex.searchsorted`, :meth:`DatetimeIndex.searchsorted`, and :meth:`PeriodIndex.searchsorted` have renamed the ``key`` argument to ``value`` (:issue:`14645`) +- :meth:`Index.searchsorted` have renamed the ``key`` argument to ``value`` (:issue:`14645`) - ``DataFrame.consolidate`` and ``Series.consolidate`` have been removed (:issue:`15501`) - Removal of the previously deprecated module ``pandas.json`` (:issue:`19944`) - The module ``pandas.tools`` has been removed (:issue:`15358`, :issue:`16005`) @@ -1386,7 +1386,7 @@ Timedelta Timezones ^^^^^^^^^ -- Bug in :meth:`DatetimeIndex.shift` where an ``AssertionError`` would raise when shifting across DST (:issue:`8616`) +- Bug in :meth:`Index.shift` where an ``AssertionError`` would raise when shifting across DST (:issue:`8616`) - Bug in :class:`Timestamp` constructor where passing an invalid timezone offset designator (``Z``) would not raise a ``ValueError`` (:issue:`8910`) - Bug in :meth:`Timestamp.replace` where replacing at a DST boundary would retain an incorrect offset (:issue:`7825`) - Bug in :meth:`Series.replace` with ``datetime64[ns, tz]`` data when replacing ``NaT`` (:issue:`11792`) @@ -1402,7 +1402,7 @@ Timezones - Bug in :func:`DataFrame.asof` that raised a ``TypeError`` when attempting to compare tz-naive and tz-aware timestamps (:issue:`21194`) - Bug when constructing a :class:`DatetimeIndex` with :class:`Timestamp` constructed with the ``replace`` method across DST (:issue:`18785`) - Bug when setting a new value with :meth:`DataFrame.loc` with a :class:`DatetimeIndex` with a DST transition (:issue:`18308`, :issue:`20724`) -- Bug in :meth:`DatetimeIndex.unique` that did not re-localize tz-aware dates correctly (:issue:`21737`) +- Bug in :meth:`Index.unique` that did not re-localize tz-aware dates correctly (:issue:`21737`) - Bug when indexing a :class:`Series` with a DST transition (:issue:`21846`) - Bug in :meth:`DataFrame.resample` and :meth:`Series.resample` where an ``AmbiguousTimeError`` or ``NonExistentTimeError`` would raise if a timezone aware timeseries ended on a DST transition (:issue:`19375`, :issue:`10117`) - Bug in :meth:`DataFrame.drop` and :meth:`Series.drop` when specifying a tz-aware Timestamp key to drop from a :class:`DatetimeIndex` with a DST transition (:issue:`21761`) @@ -1468,7 +1468,7 @@ Indexing - The traceback from a ``KeyError`` when asking ``.loc`` for a single missing label is now shorter and more clear (:issue:`21557`) - :class:`PeriodIndex` now emits a ``KeyError`` when a malformed string is looked up, which is consistent with the behavior of :class:`DatetimeIndex` (:issue:`22803`) - When ``.ix`` is asked for a missing integer label in a :class:`MultiIndex` with a first level of integer type, it now raises a ``KeyError``, consistently with the case of a flat :class:`Int64Index`, rather than falling back to positional indexing (:issue:`21593`) -- Bug in :meth:`DatetimeIndex.reindex` when reindexing a tz-naive and tz-aware :class:`DatetimeIndex` (:issue:`8306`) +- Bug in :meth:`Index.reindex` when reindexing a tz-naive and tz-aware :class:`DatetimeIndex` (:issue:`8306`) - Bug in :meth:`Series.reindex` when reindexing an empty series with a ``datetime64[ns, tz]`` dtype (:issue:`20869`) - Bug in :class:`DataFrame` when setting values with ``.loc`` and a timezone aware :class:`DatetimeIndex` (:issue:`11365`) - ``DataFrame.__getitem__`` now accepts dictionaries and dictionary keys as list-likes of labels, consistently with ``Series.__getitem__`` (:issue:`21294`) From cf1e3d32ecaa1d865aa5df4a45c065e31ca18246 Mon Sep 17 00:00:00 2001 From: Jeff Reback Date: Mon, 17 Dec 2018 08:27:55 -0500 Subject: [PATCH 4/4] typos --- doc/source/whatsnew/v0.24.0.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/source/whatsnew/v0.24.0.rst b/doc/source/whatsnew/v0.24.0.rst index b9f5be2583f17..0bd695f5a40ea 100644 --- a/doc/source/whatsnew/v0.24.0.rst +++ b/doc/source/whatsnew/v0.24.0.rst @@ -352,8 +352,8 @@ Other Enhancements - :func:`to_timedelta` now supports iso-formated timedelta strings (:issue:`21877`) - :class:`Series` and :class:`DataFrame` now support :class:`Iterable` in constructor (:issue:`2193`) - :class:`DatetimeIndex` has gained the :attr:`DatetimeIndex.timetz` attribute. This returns the local time with timezone information. (:issue:`21358`) -- :meth:`Timestamp.round`, :meth:`Timestamp.ceil`, and meth:`Timestamp.floor` for :class:`DatetimeIndex` and :class:`Timestamp` now support an ``ambiguous`` argument for handling datetimes that are rounded to ambiguous times (:issue:`18946`) -- :meth:`Timestamp.round`, :meth:`Timestamp.ceil`, and meth:`Timestamp.floor` for :class:`DatetimeIndex` and :class:`Timestamp` now support a ``nonexistent`` argument for handling datetimes that are rounded to nonexistent times. See :ref:`timeseries.timezone_nonexistent` (:issue:`22647`) +- :meth:`Timestamp.round`, :meth:`Timestamp.ceil`, and :meth:`Timestamp.floor` for :class:`DatetimeIndex` and :class:`Timestamp` now support an ``ambiguous`` argument for handling datetimes that are rounded to ambiguous times (:issue:`18946`) +- :meth:`Timestamp.round`, :meth:`Timestamp.ceil`, and :meth:`Timestamp.floor` for :class:`DatetimeIndex` and :class:`Timestamp` now support a ``nonexistent`` argument for handling datetimes that are rounded to nonexistent times. See :ref:`timeseries.timezone_nonexistent` (:issue:`22647`) - :class:`pandas.core.resample.Resampler` now is iterable like :class:`pandas.core.groupby.GroupBy` (:issue:`15314`). - :meth:`Series.resample` and :meth:`DataFrame.resample` have gained the :meth:`pandas.core.resample.Resampler.quantile` (:issue:`15023`). - :meth:`DataFrame.resample` and :meth:`Series.resample` with a :class:`PeriodIndex` will now respect the ``base`` argument in the same fashion as with a :class:`DatetimeIndex`. (:issue:`23882`) @@ -1603,7 +1603,7 @@ Groupby/Resample/Rolling - Bug in :meth:`pandas.core.groupby.GroupBy.transform` which caused missing values when the input function can accept a :class:`DataFrame` but renames it (:issue:`23455`). - Bug in :func:`pandas.core.groupby.GroupBy.nth` where column order was not always preserved (:issue:`20760`) - Bug in :meth:`pandas.core.groupby.GroupBy.rank` with ``method='dense'`` and ``pct=True`` when a group has only one member would raise a ``ZeroDivisionError`` (:issue:`23666`). -- Calling :meth:`pancas.core.groupby.GroupBy.rank` with empty groups and ``pct=True`` was raising a ``ZeroDivisionError`` (:issue:`22519`) +- Calling :meth:`pandas.core.groupby.GroupBy.rank` with empty groups and ``pct=True`` was raising a ``ZeroDivisionError`` (:issue:`22519`) - Bug in :meth:`DataFrame.resample` when resampling ``NaT`` in ``TimeDeltaIndex`` (:issue:`13223`). Reshaping