These are the changes in pandas 3.1.0. See :ref:`release` for a full changelog including other versions of pandas.
{{ header }}
- :meth:`.DataFrameGroupBy.agg` now allows for the provided
functo return a NumPy array (:issue:`63957`) - Display formatting for float sequences in DataFrame cells now respects the
display.precisionoption (:issue:`60503`).
These are bug fixes that might have notable behavior changes.
Some minimum supported versions of dependencies were updated. If installed, we now require:
| Package | Minimum Version | Required | Changed |
|---|---|---|---|
| X | X |
For optional libraries the general recommendation is to use the latest version. The following table lists the lowest version per library that is currently being tested throughout the development of pandas. Optional libraries below the lowest tested version may still work, but are not considered supported.
| Package | Minimum Version | Changed |
|---|---|---|
| X |
See :ref:`install.dependencies` and :ref:`install.optional_dependencies` for more.
- Deprecated :meth:`.DataFrameGroupBy.agg` and :meth:`.Resampler.agg` unpacking a scalar when the provided
funcreturns a Series or array of length 1; in the future this will result in the Series or array being in the result. Users should unpack the scalar infuncitself (:issue:`64014`) - Deprecated arithmetic operations between pandas objects (:class:`DataFrame`, :class:`Series`, :class:`Index`, and pandas-implemented :class:`ExtensionArray` subclasses) and list-likes other than
list,np.ndarray, :class:`ExtensionArray`, :class:`Index`, :class:`Series`, :class:`DataFrame`. For e.g.tupleorrange, explicitly cast these to a supported object instead. In a future version, these will be treated as scalar-like for pointwise operation (:issue:`62423`) - Deprecated the
.nameproperty of offset objects (e.g., :class:`~pandas.tseries.offsets.Day`, :class:`~pandas.tseries.offsets.Hour`). Use.rule_codeinstead (:issue:`64207`)
- Performance improvement in :meth:`DataFrame.__getitem__` when selecting a single column by label on a :class:`DataFrame` with duplicate column names. (:issue:`64126`).
- Performance improvement in :func:`merge` with
how="left"(:issue:`64370`) - Performance improvement in :meth:`GroupBy.quantile` (:issue:`64330`)
- Fixed bug in :meth:`Series.clip` where passing a scalar numpy array (e.g.
np.array(0)) would raise aTypeError(:issue:`59053`)
- Fixed :func:`pandas.array` to preserve mask information when converting NumPy masked arrays, converting masked values to missing values (:issue:`63879`).
- Bugs in setitem-with-expansion when adding new rows failing to keep the original dtype in some cases (:issue:`32346`, :issue:`15231`, :issue:`47503`, :issue:`6485`, :issue:`25383`, :issue:`52235`, :issue:`17026`, :issue:`56010`)
- Fixed bug in :meth:`DataFrame.sort_index` and :meth:`Series.sort_index` where passing the
levelkeyword with a single-level :class:`RangeIndex` raised anAssertionError(:issue:`64383`)
- Fixed bug in :func:`read_excel` where usage of
skiprowscould lead to an infinite loop (:issue:`64027`) - Fixed :func:`read_json` with
lines=Trueandchunksizeto respectnrowswhen the requested row count is not a multiple of the chunk size (:issue:`64025`) - Fixed :func:`read_json` with
lines=Trueandnrows=0to return an empty DataFrame (:issue:`64025`)
- Bug in :meth:`.DataFrameGroupBy.agg` when there are no groups, multiple keys, and
group_keys=False(:issue:`51445`) - Bug in :meth:`.DataFrameGroupBy.agg` would operate on the group as a whole when
argsorkwargsare supplied for the providedfunc; now this method only operates on each Series of the group (:issue:`39169`)
- In :func:`pivot_table`, when
valuesis empty, the aggregation will be computed on a Series of all NA values (:issue:`46475`)
- Fixed bug in :meth:`Series.apply` and :meth:`Series.map` where nullable integer dtypes were converted to float, causing precision loss for large integers; now the nullable dtype will be preserved (:issue:`63903`).