|
| 1 | +.. _whatsnew_150: |
| 2 | + |
| 3 | +What's new in 1.5.0 (??) |
| 4 | +------------------------ |
| 5 | + |
| 6 | +These are the changes in pandas 1.5.0. See :ref:`release` for a full changelog |
| 7 | +including other versions of pandas. |
| 8 | + |
| 9 | +{{ header }} |
| 10 | + |
| 11 | +.. --------------------------------------------------------------------------- |
| 12 | +.. _whatsnew_150.enhancements: |
| 13 | + |
| 14 | +Enhancements |
| 15 | +~~~~~~~~~~~~ |
| 16 | + |
| 17 | +.. _whatsnew_150.enhancements.styler: |
| 18 | + |
| 19 | +Styler |
| 20 | +^^^^^^ |
| 21 | + |
| 22 | + - New method :meth:`.Styler.to_string` for alternative customisable output methods (:issue:`44502`) |
| 23 | + - Various bug fixes, see below. |
| 24 | + |
| 25 | +.. _whatsnew_150.enhancements.enhancement2: |
| 26 | + |
| 27 | +enhancement2 |
| 28 | +^^^^^^^^^^^^ |
| 29 | + |
| 30 | +.. _whatsnew_150.enhancements.other: |
| 31 | + |
| 32 | +Other enhancements |
| 33 | +^^^^^^^^^^^^^^^^^^ |
| 34 | +- :meth:`MultiIndex.to_frame` now supports the argument ``allow_duplicates`` and raises on duplicate labels if it is missing or False (:issue:`45245`) |
| 35 | +- :class:`StringArray` now accepts array-likes containing nan-likes (``None``, ``np.nan``) for the ``values`` parameter in its constructor in addition to strings and :attr:`pandas.NA`. (:issue:`40839`) |
| 36 | +- Improved the rendering of ``categories`` in :class:`CategoricalIndex` (:issue:`45218`) |
| 37 | +- :meth:`to_numeric` now preserves float64 arrays when downcasting would generate values not representable in float32 (:issue:`43693`) |
| 38 | +- :meth:`.GroupBy.min` and :meth:`.GroupBy.max` now supports `Numba <https://numba.pydata.org/>`_ execution with the ``engine`` keyword (:issue:`45428`) |
| 39 | +- |
| 40 | + |
| 41 | +.. --------------------------------------------------------------------------- |
| 42 | +.. _whatsnew_150.notable_bug_fixes: |
| 43 | + |
| 44 | +Notable bug fixes |
| 45 | +~~~~~~~~~~~~~~~~~ |
| 46 | + |
| 47 | +These are bug fixes that might have notable behavior changes. |
| 48 | + |
| 49 | +.. _whatsnew_150.notable_bug_fixes.notable_bug_fix1: |
| 50 | + |
| 51 | +notable_bug_fix1 |
| 52 | +^^^^^^^^^^^^^^^^ |
| 53 | + |
| 54 | +.. _whatsnew_150.notable_bug_fixes.notable_bug_fix2: |
| 55 | + |
| 56 | +notable_bug_fix2 |
| 57 | +^^^^^^^^^^^^^^^^ |
| 58 | + |
| 59 | +.. --------------------------------------------------------------------------- |
| 60 | +.. _whatsnew_150.api_breaking: |
| 61 | + |
| 62 | +Backwards incompatible API changes |
| 63 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 64 | + |
| 65 | +.. _whatsnew_150.api_breaking.deps: |
| 66 | + |
| 67 | +Increased minimum versions for dependencies |
| 68 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 69 | +Some minimum supported versions of dependencies were updated. |
| 70 | +If installed, we now require: |
| 71 | + |
| 72 | ++-----------------+-----------------+----------+---------+ |
| 73 | +| Package | Minimum Version | Required | Changed | |
| 74 | ++=================+=================+==========+=========+ |
| 75 | +| mypy (dev) | 0.931 | | X | |
| 76 | ++-----------------+-----------------+----------+---------+ |
| 77 | + |
| 78 | + |
| 79 | +For `optional libraries <https://pandas.pydata.org/docs/getting_started/install.html>`_ the general recommendation is to use the latest version. |
| 80 | +The following table lists the lowest version per library that is currently being tested throughout the development of pandas. |
| 81 | +Optional libraries below the lowest tested version may still work, but are not considered supported. |
| 82 | + |
| 83 | ++-----------------+-----------------+---------+ |
| 84 | +| Package | Minimum Version | Changed | |
| 85 | ++=================+=================+=========+ |
| 86 | +| | | X | |
| 87 | ++-----------------+-----------------+---------+ |
| 88 | + |
| 89 | +See :ref:`install.dependencies` and :ref:`install.optional_dependencies` for more. |
| 90 | + |
| 91 | + |
| 92 | +.. _whatsnew_150.read_xml_dtypes: |
| 93 | + |
| 94 | +read_xml now supports ``dtype``, ``converters``, and ``parse_dates`` |
| 95 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 96 | + |
| 97 | +Similar to other IO methods, :func:`pandas.read_xml` now supports assigning specific dtypes to columns, |
| 98 | +apply converter methods, and parse dates (:issue:`43567`). |
| 99 | + |
| 100 | +.. ipython:: python |
| 101 | +
|
| 102 | + xml_dates = """<?xml version='1.0' encoding='utf-8'?> |
| 103 | + <data> |
| 104 | + <row> |
| 105 | + <shape>square</shape> |
| 106 | + <degrees>00360</degrees> |
| 107 | + <sides>4.0</sides> |
| 108 | + <date>2020-01-01</date> |
| 109 | + </row> |
| 110 | + <row> |
| 111 | + <shape>circle</shape> |
| 112 | + <degrees>00360</degrees> |
| 113 | + <sides/> |
| 114 | + <date>2021-01-01</date> |
| 115 | + </row> |
| 116 | + <row> |
| 117 | + <shape>triangle</shape> |
| 118 | + <degrees>00180</degrees> |
| 119 | + <sides>3.0</sides> |
| 120 | + <date>2022-01-01</date> |
| 121 | + </row> |
| 122 | + </data>""" |
| 123 | +
|
| 124 | + df = pd.read_xml( |
| 125 | + xml_dates, |
| 126 | + dtype={'sides': 'Int64'}, |
| 127 | + converters={'degrees': str}, |
| 128 | + parse_dates=['date'] |
| 129 | + ) |
| 130 | + df |
| 131 | + df.dtypes |
| 132 | +
|
| 133 | +.. _whatsnew_150.api_breaking.other: |
| 134 | + |
| 135 | +Other API changes |
| 136 | +^^^^^^^^^^^^^^^^^ |
| 137 | +- |
| 138 | +- |
| 139 | + |
| 140 | +.. --------------------------------------------------------------------------- |
| 141 | +.. _whatsnew_150.deprecations: |
| 142 | + |
| 143 | +Deprecations |
| 144 | +~~~~~~~~~~~~ |
| 145 | + |
| 146 | +.. _whatsnew_150.deprecations.int_slicing_series: |
| 147 | + |
| 148 | +In a future version, integer slicing on a :class:`Series` with a :class:`Int64Index` or :class:`RangeIndex` will be treated as *label-based*, not positional. This will make the behavior consistent with other :meth:`Series.__getitem__` and :meth:`Series.__setitem__` behaviors (:issue:`45162`). |
| 149 | + |
| 150 | +For example: |
| 151 | + |
| 152 | +.. ipython:: python |
| 153 | +
|
| 154 | + ser = pd.Series([1, 2, 3, 4, 5], index=[2, 3, 5, 7, 11]) |
| 155 | +
|
| 156 | +In the old behavior, ``ser[2:4]`` treats the slice as positional: |
| 157 | + |
| 158 | +*Old behavior*: |
| 159 | + |
| 160 | +.. code-block:: ipython |
| 161 | +
|
| 162 | + In [3]: ser[2:4] |
| 163 | + Out[3]: |
| 164 | + 5 3 |
| 165 | + 7 4 |
| 166 | + dtype: int64 |
| 167 | +
|
| 168 | +In a future version, this will be treated as label-based: |
| 169 | + |
| 170 | +*Future behavior*: |
| 171 | + |
| 172 | +.. code-block:: ipython |
| 173 | +
|
| 174 | + In [4]: ser.loc[2:4] |
| 175 | + Out[4]: |
| 176 | + 2 1 |
| 177 | + 3 2 |
| 178 | + dtype: int64 |
| 179 | +
|
| 180 | +To retain the old behavior, use ``series.iloc[i:j]``. To get the future behavior, |
| 181 | +use ``series.loc[i:j]``. |
| 182 | + |
| 183 | +Slicing on a :class:`DataFrame` will not be affected. |
| 184 | + |
| 185 | +.. _whatsnew_150.deprecations.other: |
| 186 | + |
| 187 | +Other Deprecations |
| 188 | +^^^^^^^^^^^^^^^^^^ |
| 189 | +- Deprecated the keyword ``line_terminator`` in :meth:`DataFrame.to_csv` and :meth:`Series.to_csv`, use ``lineterminator`` instead; this is for consistency with :func:`read_csv` and the standard library 'csv' module (:issue:`9568`) |
| 190 | +- Deprecated behavior of :meth:`SparseArray.astype`, :meth:`Series.astype`, and :meth:`DataFrame.astype` with :class:`SparseDtype` when passing a non-sparse ``dtype``. In a future version, this will cast to that non-sparse dtype instead of wrapping it in a :class:`SparseDtype` (:issue:`34457`) |
| 191 | +- Deprecated behavior of :meth:`DatetimeIndex.intersection` and :meth:`DatetimeIndex.symmetric_difference` (``union`` behavior was already deprecated in version 1.3.0) with mixed timezones; in a future version both will be cast to UTC instead of object dtype (:issue:`39328`, :issue:`45357`) |
| 192 | +- Deprecated :meth:`DataFrame.iteritems`, :meth:`Series.iteritems`, :meth:`HDFStore.iteritems` in favor of :meth:`DataFrame.items`, :meth:`Series.items`, :meth:`HDFStore.items` (:issue:`45321`) |
| 193 | +- Deprecated :meth:`Series.is_monotonic` and :meth:`Index.is_monotonic` in favor of :meth:`Series.is_monotonic_increasing` and :meth:`Index.is_monotonic_increasing` (:issue:`45422`, :issue:`21335`) |
| 194 | +- Deprecated the ``__array_wrap__`` method of DataFrame and Series, rely on standard numpy ufuncs instead (:issue:`45451`) |
| 195 | +- |
| 196 | + |
| 197 | + |
| 198 | +.. --------------------------------------------------------------------------- |
| 199 | +.. _whatsnew_150.performance: |
| 200 | + |
| 201 | +Performance improvements |
| 202 | +~~~~~~~~~~~~~~~~~~~~~~~~ |
| 203 | +- Performance improvement in :meth:`.GroupBy.transform` for some user-defined DataFrame -> Series functions (:issue:`45387`) |
| 204 | +- Performance improvement in :meth:`DataFrame.duplicated` when subset consists of only one column (:issue:`45236`) |
| 205 | +- |
| 206 | + |
| 207 | +.. --------------------------------------------------------------------------- |
| 208 | +.. _whatsnew_150.bug_fixes: |
| 209 | + |
| 210 | +Bug fixes |
| 211 | +~~~~~~~~~ |
| 212 | + |
| 213 | +Categorical |
| 214 | +^^^^^^^^^^^ |
| 215 | +- Bug in :meth:`CategoricalIndex.union` when the index's categories are integer-dtype and the index contains ``NaN`` values incorrectly raising instead of casting to ``float64`` (:issue:`45362`) |
| 216 | +- |
| 217 | + |
| 218 | +Datetimelike |
| 219 | +^^^^^^^^^^^^ |
| 220 | +- Bug in :meth:`DataFrame.quantile` with datetime-like dtypes and no rows incorrectly returning ``float64`` dtype instead of retaining datetime-like dtype (:issue:`41544`) |
| 221 | +- Bug in :func:`to_datetime` with sequences of ``np.str_`` objects incorrectly raising (:issue:`32264`) |
| 222 | +- Bug in :class:`Timestamp` construction when passing datetime components as positional arguments and ``tzinfo`` as a keyword argument incorrectly raising (:issue:`31929`) |
| 223 | +- |
| 224 | + |
| 225 | +Timedelta |
| 226 | +^^^^^^^^^ |
| 227 | +- |
| 228 | + |
| 229 | +Timezones |
| 230 | +^^^^^^^^^ |
| 231 | +- |
| 232 | +- |
| 233 | + |
| 234 | +Numeric |
| 235 | +^^^^^^^ |
| 236 | +- Bug in operations with array-likes with ``dtype="boolean"`` and :attr:`NA` incorrectly altering the array in-place (:issue:`45421`) |
| 237 | +- |
| 238 | + |
| 239 | +Conversion |
| 240 | +^^^^^^^^^^ |
| 241 | +- Bug in :meth:`DataFrame.astype` not preserving subclasses (:issue:`40810`) |
| 242 | +- Bug in constructing a :class:`Series` from a float-containing list or a floating-dtype ndarray-like (e.g. ``dask.Array``) and an integer dtype raising instead of casting like we would with an ``np.ndarray`` (:issue:`40110`) |
| 243 | +- Bug in :meth:`Float64Index.astype` to unsigned integer dtype incorrectly casting to ``np.int64`` dtype (:issue:`45309`) |
| 244 | +- Bug in :meth:`Series.astype` and :meth:`DataFrame.astype` from floating dtype to unsigned integer dtype failing to raise in the presence of negative values (:issue:`45151`) |
| 245 | +- Bug in :func:`array` with ``FloatingDtype`` and values containing float-castable strings incorrectly raising (:issue:`45424`) |
| 246 | +- |
| 247 | + |
| 248 | +Strings |
| 249 | +^^^^^^^ |
| 250 | +- |
| 251 | +- |
| 252 | + |
| 253 | +Interval |
| 254 | +^^^^^^^^ |
| 255 | +- Bug in :meth:`IntervalArray.__setitem__` when setting ``np.nan`` into an integer-backed array raising ``ValueError`` instead of ``TypeError`` (:issue:`45484`) |
| 256 | +- |
| 257 | + |
| 258 | +Indexing |
| 259 | +^^^^^^^^ |
| 260 | +- Bug in :meth:`loc.__getitem__` with a list of keys causing an internal inconsistency that could lead to a disconnect between ``frame.at[x, y]`` vs ``frame[y].loc[x]`` (:issue:`22372`) |
| 261 | +- Bug in :meth:`DataFrame.iloc` where indexing a single row on a :class:`DataFrame` with a single ExtensionDtype column gave a copy instead of a view on the underlying data (:issue:`45241`) |
| 262 | +- Bug in :meth:`Series.__setitem__` with a non-integer :class:`Index` when using an integer key to set a value that cannot be set inplace where a ``ValueError`` was raised insead of casting to a common dtype (:issue:`45070`) |
| 263 | +- Bug when setting a value too large for a :class:`Series` dtype failing to coerce to a common type (:issue:`26049`, :issue:`32878`) |
| 264 | +- Bug in :meth:`loc.__setitem__` treating ``range`` keys as positional instead of label-based (:issue:`45479`) |
| 265 | +- Bug in :meth:`Series.__setitem__` when setting ``boolean`` dtype values containing ``NA`` incorrectly raising instead of casting to ``boolean`` dtype (:issue:`45462`) |
| 266 | +- Bug in :meth:`Series.__setitem__` where setting :attr:`NA` into a numeric-dtpye :class:`Series` would incorrectly upcast to object-dtype rather than treating the value as ``np.nan`` (:issue:`44199`) |
| 267 | +- Bug in getting a column from a DataFrame with an object-dtype row index with datetime-like values: the resulting Series now preserves the exact object-dtype Index from the parent DataFrame (:issue:`42950`) |
| 268 | +- |
| 269 | + |
| 270 | +Missing |
| 271 | +^^^^^^^ |
| 272 | +- |
| 273 | +- |
| 274 | + |
| 275 | +MultiIndex |
| 276 | +^^^^^^^^^^ |
| 277 | +- |
| 278 | +- |
| 279 | + |
| 280 | +I/O |
| 281 | +^^^ |
| 282 | +- Bug in :meth:`DataFrame.to_stata` where no error is raised if the :class:`DataFrame` contains ``-np.inf`` (:issue:`45350`) |
| 283 | +- Bug in :meth:`DataFrame.info` where a new line at the end of the output is omitted when called on an empty :class:`DataFrame` (:issue:`45494`) |
| 284 | +- Bug in :func:`read_parquet` when ``engine="pyarrow"`` which caused partial write to disk when column of unsupported datatype was passed (:issue:`44914`) |
| 285 | +- |
| 286 | + |
| 287 | +Period |
| 288 | +^^^^^^ |
| 289 | +- |
| 290 | +- |
| 291 | + |
| 292 | +Plotting |
| 293 | +^^^^^^^^ |
| 294 | +- Bug in :meth:`DataFrame.plot.barh` that prevented labeling the x-axis and ``xlabel`` updating the y-axis label (:issue:`45144`) |
| 295 | +- Bug in :meth:`DataFrame.plot.box` that prevented labeling the x-axis (:issue:`45463`) |
| 296 | +- Bug in :meth:`DataFrame.boxplot` that prevented passing in ``xlabel`` and ``ylabel`` (:issue:`45463`) |
| 297 | +- Bug in :meth:`DataFrame.boxplot` that prevented specifying ``vert=False`` (:issue:`36918`) |
| 298 | +- The function :meth:`DataFrame.scatter` now accepts ``color`` as an alias for ``c`` and ``size`` as an alias for ``s`` for consistency to other plotting functions (:issue:`44670`) |
| 299 | +- |
| 300 | + |
| 301 | +Groupby/resample/rolling |
| 302 | +^^^^^^^^^^^^^^^^^^^^^^^^ |
| 303 | +- Bug in :meth:`DataFrame.resample` ignoring ``closed="right"`` on :class:`TimedeltaIndex` (:issue:`45414`) |
| 304 | +- |
| 305 | + |
| 306 | +Reshaping |
| 307 | +^^^^^^^^^ |
| 308 | +- Bug in :func:`concat` between a :class:`Series` with integer dtype and another with :class:`CategoricalDtype` with integer categories and containing ``NaN`` values casting to object dtype instead of ``float64`` (:issue:`45359`) |
| 309 | +- |
| 310 | + |
| 311 | +Sparse |
| 312 | +^^^^^^ |
| 313 | +- |
| 314 | +- |
| 315 | + |
| 316 | +ExtensionArray |
| 317 | +^^^^^^^^^^^^^^ |
| 318 | +- Bug in :meth:`IntegerArray.searchsorted` and :meth:`FloatingArray.searchsorted` returning inconsistent results when acting on ``np.nan`` (:issue:`45255`) |
| 319 | +- |
| 320 | + |
| 321 | +Styler |
| 322 | +^^^^^^ |
| 323 | +- Minor bug when attempting to apply styling functions to an empty DataFrame subset (:issue:`45313`) |
| 324 | +- |
| 325 | + |
| 326 | +Other |
| 327 | +^^^^^ |
| 328 | +- Bug in :meth:`Series.asof` and :meth:`DataFrame.asof` incorrectly casting bool-dtype results to ``float64`` dtype (:issue:`16063`) |
| 329 | +- |
| 330 | + |
| 331 | +.. ***DO NOT USE THIS SECTION*** |
| 332 | +
|
| 333 | +- |
| 334 | +- |
| 335 | + |
| 336 | +.. --------------------------------------------------------------------------- |
| 337 | +.. _whatsnew_150.contributors: |
| 338 | + |
| 339 | +Contributors |
| 340 | +~~~~~~~~~~~~ |
0 commit comments