Skip to content

Commit f66749d

Browse files
authored
Merge branch 'main' into indexs_50942
2 parents 31c75b2 + 00a7c41 commit f66749d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1032
-516
lines changed

doc/source/getting_started/install.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ index from the PyPI registry of anaconda.org. You can install it by running.
112112

113113
.. code-block:: shell
114114
115-
pip install --pre --extra-index https://pypi.anaconda.org/scientific-python-nightly-wheels/simple pandas
115+
pip install --pre --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple pandas
116116
117117
.. note::
118118
You might be required to uninstall an existing version of pandas to install the development version.

doc/source/whatsnew/v3.0.0.rst

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,71 @@ In cases with mixed-resolution inputs, the highest resolution is used:
374374
In [2]: pd.to_datetime([pd.Timestamp("2024-03-22 11:43:01"), "2024-03-22 11:43:01.002"]).dtype
375375
Out[2]: dtype('<M8[ns]')
376376
377+
.. _whatsnew_300.api_breaking.concat_datetime_sorting:
378+
379+
:func:`concat` no longer ignores ``sort`` when all objects have a :class:`DatetimeIndex`
380+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
381+
382+
When all objects passed to :func:`concat` have a :class:`DatetimeIndex`,
383+
passing ``sort=False`` will now result in the non-concatenation axis not
384+
being sorted. Previously, the result would always be sorted along
385+
the non-concatenation axis even when ``sort=False`` is passed. :issue:`57335`
386+
387+
If you do not specify the ``sort`` argument, pandas will continue to return a
388+
sorted result but this behavior is deprecated and you will receive a warning.
389+
In order to make this less noisy for users, pandas checks if not sorting would
390+
impact the result and only warns when it would. This check can be expensive,
391+
and users can skip the check by explicitly specifying ``sort=True`` or
392+
``sort=False``.
393+
394+
This deprecation can also impact pandas' internal usage of :func:`concat`.
395+
Here cases where :func:`concat` was sorting a :class:`DatetimeIndex` but not
396+
other indexes are considered bugs and have been fixed as noted below. However
397+
it is possible some have been missed. In order to be cautious here, pandas has *not*
398+
added ``sort=False`` to any internal calls where we believe behavior should not change.
399+
If we have missed something, users will not experience a behavior change but they
400+
will receive a warning about :func:`concat` even though they are not directly
401+
calling this function. If this does occur, we ask users to open an issue so that
402+
we may address any potential behavior changes.
403+
404+
.. ipython:: python
405+
406+
idx1 = pd.date_range("2025-01-02", periods=3, freq="h")
407+
df1 = pd.DataFrame({"a": [1, 2, 3]}, index=idx1)
408+
df1
409+
410+
idx2 = pd.date_range("2025-01-01", periods=3, freq="h")
411+
df2 = pd.DataFrame({"b": [1, 2, 3]}, index=idx2)
412+
df2
413+
414+
*Old behavior*
415+
416+
.. code-block:: ipython
417+
418+
In [3]: pd.concat([df1, df2], axis=1, sort=False)
419+
Out[3]:
420+
a b
421+
2025-01-01 00:00:00 NaN 1.0
422+
2025-01-01 01:00:00 NaN 2.0
423+
2025-01-01 02:00:00 NaN 3.0
424+
2025-01-02 00:00:00 1.0 NaN
425+
2025-01-02 01:00:00 2.0 NaN
426+
2025-01-02 02:00:00 3.0 NaN
427+
428+
*New behavior*
429+
430+
.. ipython:: python
431+
432+
pd.concat([df1, df2], axis=1, sort=False)
433+
434+
Cases where pandas' internal usage of :func:`concat` resulted in inconsistent sorting
435+
that are now fixed in this release are as follows.
436+
437+
- :meth:`Series.apply` and :meth:`DataFrame.apply` with a list-like or dict-like ``func`` argument.
438+
- :meth:`Series.shift`, :meth:`DataFrame.shift`, :meth:`.SeriesGroupBy.shift`, :meth:`.DataFrameGroupBy.shift` with the ``periods`` argument a list of length greater than 1.
439+
- :meth:`DataFrame.join` with ``other`` a list of one or more Series or DataFrames and ``how="inner"``, ``how="left"``, or ``how="right"``.
440+
- :meth:`Series.str.cat` with ``others`` a Series or DataFrame.
441+
377442
.. _whatsnew_300.api_breaking.value_counts_sorting:
378443

379444
Changed behavior in :meth:`DataFrame.value_counts` and :meth:`DataFrameGroupBy.value_counts` when ``sort=False``
@@ -742,6 +807,7 @@ Other Deprecations
742807
- Deprecated option "future.no_silent_downcasting", as it is no longer used. In a future version accessing this option will raise (:issue:`59502`)
743808
- Deprecated passing non-Index types to :meth:`Index.join`; explicitly convert to Index first (:issue:`62897`)
744809
- Deprecated silent casting of non-datetime 'other' to datetime in :meth:`Series.combine_first` (:issue:`62931`)
810+
- Deprecated silently casting strings to :class:`Timedelta` in binary operations with :class:`Timedelta` (:issue:`59653`)
745811
- Deprecated slicing on a :class:`Series` or :class:`DataFrame` with a :class:`DatetimeIndex` using a ``datetime.date`` object, explicitly cast to :class:`Timestamp` instead (:issue:`35830`)
746812
- Deprecated support for the Dataframe Interchange Protocol (:issue:`56732`)
747813
- Deprecated the 'inplace' keyword from :meth:`Resampler.interpolate`, as passing ``True`` raises ``AttributeError`` (:issue:`58690`)
@@ -1067,6 +1133,7 @@ Indexing
10671133
^^^^^^^^
10681134
- Bug in :meth:`DataFrame.__getitem__` returning modified columns when called with ``slice`` in Python 3.12 (:issue:`57500`)
10691135
- Bug in :meth:`DataFrame.__getitem__` when slicing a :class:`DataFrame` with many rows raised an ``OverflowError`` (:issue:`59531`)
1136+
- Bug in :meth:`DataFrame.__setitem__` on an empty :class:`DataFrame` with a tuple corrupting the frame (:issue:`54385`)
10701137
- Bug in :meth:`DataFrame.from_records` throwing a ``ValueError`` when passed an empty list in ``index`` (:issue:`58594`)
10711138
- Bug in :meth:`DataFrame.loc` and :meth:`DataFrame.iloc` returning incorrect dtype when selecting from a :class:`DataFrame` with mixed data types. (:issue:`60600`)
10721139
- Bug in :meth:`DataFrame.loc` with inconsistent behavior of loc-set with 2 given indexes to Series (:issue:`59933`)
@@ -1189,6 +1256,7 @@ Groupby/resample/rolling
11891256
- Bug in :meth:`DataFrameGroupby.transform` and :meth:`SeriesGroupby.transform` with a reducer and ``observed=False`` that coerces dtype to float when there are unobserved categories. (:issue:`55326`)
11901257
- Bug in :meth:`Rolling.apply` for ``method="table"`` where column order was not being respected due to the columns getting sorted by default. (:issue:`59666`)
11911258
- Bug in :meth:`Rolling.apply` where the applied function could be called on fewer than ``min_period`` periods if ``method="table"``. (:issue:`58868`)
1259+
- Bug in :meth:`Rolling.skew` incorrectly computing skewness for windows following outliers due to numerical instability. The calculation now properly handles catastrophic cancellation by recomputing affected windows (:issue:`47461`)
11921260
- Bug in :meth:`Series.resample` could raise when the date range ended shortly before a non-existent time. (:issue:`58380`)
11931261
- Bug in :meth:`Series.resample` raising error when resampling non-nanosecond resolutions out of bounds for nanosecond precision (:issue:`57427`)
11941262

0 commit comments

Comments
 (0)