Skip to content

Commit b89b9d4

Browse files
committed
Merge remote-tracking branch 'upstream/main' into ref/index_equiv
2 parents c8506a5 + d8eb201 commit b89b9d4

Some content is hidden

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

63 files changed

+622
-478
lines changed

ci/code_checks.sh

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
144144

145145
MSG='Partially validate docstrings (GL08)' ; echo $MSG
146146
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=GL08 --ignore_functions \
147-
pandas.ExcelFile.book\
148147
pandas.Index.empty\
149148
pandas.Index.names\
150149
pandas.Index.view\
@@ -490,23 +489,11 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
490489
pandas.errors.AbstractMethodError\
491490
pandas.errors.UndefinedVariableError\
492491
pandas.get_option\
493-
pandas.io.formats.style.Styler.to_excel\
494-
pandas.melt\
495-
pandas.option_context\
496-
pandas.read_fwf\
497-
pandas.reset_option # There should be no backslash in the final line, please keep this comment in the last ignored function
492+
pandas.io.formats.style.Styler.to_excel # There should be no backslash in the final line, please keep this comment in the last ignored function
498493
RET=$(($RET + $?)) ; echo $MSG "DONE"
499494

500495
MSG='Partially validate docstrings (PR07)' ; echo $MSG
501496
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=PR07 --ignore_functions \
502-
pandas.DataFrame.get\
503-
pandas.DataFrame.rolling\
504-
pandas.DataFrame.to_hdf\
505-
pandas.DatetimeIndex.indexer_between_time\
506-
pandas.DatetimeIndex.mean\
507-
pandas.HDFStore.append\
508-
pandas.HDFStore.get\
509-
pandas.HDFStore.put\
510497
pandas.Index\
511498
pandas.Index.append\
512499
pandas.Index.copy\
@@ -614,39 +601,21 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
614601

615602
MSG='Partially validate docstrings (RT03)' ; echo $MSG
616603
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=RT03 --ignore_functions \
617-
pandas.DataFrame.expanding\
618-
pandas.DataFrame.filter\
619-
pandas.DataFrame.first_valid_index\
620-
pandas.DataFrame.get\
621604
pandas.DataFrame.hist\
622605
pandas.DataFrame.infer_objects\
623606
pandas.DataFrame.kurt\
624607
pandas.DataFrame.kurtosis\
625-
pandas.DataFrame.last_valid_index\
626608
pandas.DataFrame.mask\
627609
pandas.DataFrame.max\
628610
pandas.DataFrame.mean\
629611
pandas.DataFrame.median\
630612
pandas.DataFrame.min\
631-
pandas.DataFrame.nsmallest\
632-
pandas.DataFrame.nunique\
633-
pandas.DataFrame.pipe\
634-
pandas.DataFrame.plot.box\
635-
pandas.DataFrame.plot.density\
636-
pandas.DataFrame.plot.kde\
637-
pandas.DataFrame.plot.scatter\
638-
pandas.DataFrame.pop\
639613
pandas.DataFrame.prod\
640614
pandas.DataFrame.product\
641-
pandas.DataFrame.reindex\
642-
pandas.DataFrame.reorder_levels\
643615
pandas.DataFrame.sem\
644616
pandas.DataFrame.skew\
645617
pandas.DataFrame.std\
646618
pandas.DataFrame.sum\
647-
pandas.DataFrame.swapaxes\
648-
pandas.DataFrame.to_numpy\
649-
pandas.DataFrame.to_orc\
650619
pandas.DataFrame.to_parquet\
651620
pandas.DataFrame.unstack\
652621
pandas.DataFrame.value_counts\
@@ -866,29 +835,18 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
866835
pandas.plotting.parallel_coordinates\
867836
pandas.plotting.radviz\
868837
pandas.plotting.table\
869-
pandas.read_orc\
870-
pandas.read_sas\
871-
pandas.read_spss\
872-
pandas.read_stata\
873-
pandas.set_eng_float_format\
874-
pandas.timedelta_range\
875-
pandas.util.hash_pandas_object # There should be no backslash in the final line, please keep this comment in the last ignored function
838+
pandas.set_eng_float_format # There should be no backslash in the final line, please keep this comment in the last ignored function
876839
RET=$(($RET + $?)) ; echo $MSG "DONE"
877840

878841
MSG='Partially validate docstrings (SA01)' ; echo $MSG
879842
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=SA01 --ignore_functions \
880-
pandas.BooleanDtype\
881843
pandas.Categorical.__array__\
882-
pandas.Categorical.as_ordered\
883-
pandas.Categorical.as_unordered\
884844
pandas.Categorical.codes\
885845
pandas.Categorical.dtype\
886846
pandas.Categorical.from_codes\
887847
pandas.Categorical.ordered\
888848
pandas.CategoricalDtype.categories\
889849
pandas.CategoricalDtype.ordered\
890-
pandas.CategoricalIndex.as_ordered\
891-
pandas.CategoricalIndex.as_unordered\
892850
pandas.CategoricalIndex.codes\
893851
pandas.CategoricalIndex.ordered\
894852
pandas.DataFrame.__dataframe__\
@@ -1085,8 +1043,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
10851043
pandas.Series.backfill\
10861044
pandas.Series.bfill\
10871045
pandas.Series.cat\
1088-
pandas.Series.cat.as_ordered\
1089-
pandas.Series.cat.as_unordered\
10901046
pandas.Series.cat.codes\
10911047
pandas.Series.cat.ordered\
10921048
pandas.Series.copy\
@@ -1189,7 +1145,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
11891145
pandas.Series.update\
11901146
pandas.Series.var\
11911147
pandas.SparseDtype\
1192-
pandas.StringDtype\
11931148
pandas.Timedelta\
11941149
pandas.Timedelta.as_unit\
11951150
pandas.Timedelta.asm8\

doc/source/user_guide/timeseries.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,8 +1327,8 @@ frequencies. We will refer to these aliases as *period aliases*.
13271327

13281328
.. deprecated:: 2.2.0
13291329

1330-
Aliases ``A``, ``H``, ``T``, ``S``, ``L``, ``U``, and ``N`` are deprecated in favour of the aliases
1331-
``Y``, ``h``, ``min``, ``s``, ``ms``, ``us``, and ``ns``.
1330+
Aliases ``H``, ``T``, ``S``, ``L``, ``U``, and ``N`` are deprecated in favour of the aliases
1331+
``h``, ``min``, ``s``, ``ms``, ``us``, and ``ns``.
13321332

13331333

13341334
Combining aliases

doc/source/whatsnew/v3.0.0.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,11 @@ Removal of prior version deprecations/changes
203203
- Enforced deprecation of :meth:`.DataFrameGroupBy.get_group` and :meth:`.SeriesGroupBy.get_group` allowing the ``name`` argument to be a non-tuple when grouping by a list of length 1 (:issue:`54155`)
204204
- Enforced deprecation of ``axis=None`` acting the same as ``axis=0`` in the DataFrame reductions ``sum``, ``prod``, ``std``, ``var``, and ``sem``, passing ``axis=None`` will now reduce over both axes; this is particularly the case when doing e.g. ``numpy.sum(df)`` (:issue:`21597`)
205205
- Enforced deprecation of passing a dictionary to :meth:`SeriesGroupBy.agg` (:issue:`52268`)
206+
- Enforced deprecation of string ``AS`` denoting frequency in :class:`YearBegin` and strings ``AS-DEC``, ``AS-JAN``, etc. denoting annual frequencies with various fiscal year starts (:issue:`57793`)
207+
- Enforced deprecation of string ``A`` denoting frequency in :class:`YearEnd` and strings ``A-DEC``, ``A-JAN``, etc. denoting annual frequencies with various fiscal year ends (:issue:`57699`)
208+
- Enforced deprecation of string ``BAS`` denoting frequency in :class:`BYearBegin` and strings ``BAS-DEC``, ``BAS-JAN``, etc. denoting annual frequencies with various fiscal year starts (:issue:`57793`)
209+
- Enforced deprecation of string ``BA`` denoting frequency in :class:`BYearEnd` and strings ``BA-DEC``, ``BA-JAN``, etc. denoting annual frequencies with various fiscal year ends (:issue:`57793`)
210+
- Enforced deprecation of the behavior of :func:`concat` when ``len(keys) != len(objs)`` would truncate to the shorter of the two. Now this raises a ``ValueError`` (:issue:`43485`)
206211
- Enforced silent-downcasting deprecation for :ref:`all relevant methods <whatsnew_220.silent_downcasting>` (:issue:`54710`)
207212
- In :meth:`DataFrame.stack`, the default value of ``future_stack`` is now ``True``; specifying ``False`` will raise a ``FutureWarning`` (:issue:`55448`)
208213
- Iterating over a :class:`.DataFrameGroupBy` or :class:`.SeriesGroupBy` will return tuples of length 1 for the groups when grouping by ``level`` a list of length 1 (:issue:`50064`)
@@ -254,8 +259,11 @@ Removal of prior version deprecations/changes
254259

255260
Performance improvements
256261
~~~~~~~~~~~~~~~~~~~~~~~~
262+
- :attr:`Categorical.categories` returns a :class:`RangeIndex` columns instead of an :class:`Index` if the constructed ``values`` was a ``range``. (:issue:`57787`)
263+
- :func:`concat` returns a :class:`RangeIndex` level in the :class:`MultiIndex` result when ``keys`` is a ``range`` or :class:`RangeIndex` (:issue:`57542`)
257264
- :meth:`RangeIndex.append` returns a :class:`RangeIndex` instead of a :class:`Index` when appending values that could continue the :class:`RangeIndex` (:issue:`57467`)
258265
- :meth:`Series.str.extract` returns a :class:`RangeIndex` columns instead of an :class:`Index` column when possible (:issue:`57542`)
266+
- :meth:`Series.str.partition` with :class:`ArrowDtype` returns a :class:`RangeIndex` columns instead of an :class:`Index` column when possible (:issue:`57768`)
259267
- Performance improvement in :class:`DataFrame` when ``data`` is a ``dict`` and ``columns`` is specified (:issue:`24368`)
260268
- Performance improvement in :meth:`DataFrame.join` for sorted but non-unique indexes (:issue:`56941`)
261269
- Performance improvement in :meth:`DataFrame.join` when left and/or right are non-unique and ``how`` is ``"left"``, ``"right"``, or ``"inner"`` (:issue:`56817`)
@@ -277,10 +285,12 @@ Performance improvements
277285

278286
Bug fixes
279287
~~~~~~~~~
288+
- Fixed bug in :class:`SparseDtype` for equal comparison with na fill value. (:issue:`54770`)
280289
- Fixed bug in :meth:`DataFrame.join` inconsistently setting result index name (:issue:`55815`)
281290
- Fixed bug in :meth:`DataFrame.to_string` that raised ``StopIteration`` with nested DataFrames. (:issue:`16098`)
282291
- Fixed bug in :meth:`DataFrame.update` bool dtype being converted to object (:issue:`55509`)
283292
- Fixed bug in :meth:`Series.diff` allowing non-integer values for the ``periods`` argument. (:issue:`56607`)
293+
- Fixed bug in :meth:`Series.rank` that doesn't preserve missing values for nullable integers when ``na_option='keep'``. (:issue:`56976`)
284294

285295
Categorical
286296
^^^^^^^^^^^

doc/sphinxext/announce.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
$ ./scripts/announce.py $GITHUB v1.11.0..v1.11.1 > announce.rst
3333
3434
"""
35+
3536
import codecs
3637
import os
3738
import re

doc/sphinxext/contributors.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
While the v0.23.1 tag does not exist, that will use the HEAD of the
1515
branch as the end of the revision range.
1616
"""
17+
1718
from announce import build_components
1819
from docutils import nodes
1920
from docutils.parsers.rst import Directive

pandas/_libs/src/datetime/pd_datetime.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ This file is derived from NumPy 1.7. See NUMPY_LICENSE.txt
2020
#include <Python.h>
2121

2222
#include "datetime.h"
23+
/* Need to import_array for np_datetime.c (for NumPy 1.x support only) */
24+
#define PY_ARRAY_UNIQUE_SYMBOL PANDAS_DATETIME_NUMPY
25+
#include "numpy/ndarrayobject.h"
2326
#include "pandas/datetime/pd_datetime.h"
2427
#include "pandas/portable.h"
2528

@@ -255,5 +258,6 @@ static struct PyModuleDef pandas_datetimemodule = {
255258

256259
PyMODINIT_FUNC PyInit_pandas_datetime(void) {
257260
PyDateTime_IMPORT;
261+
import_array();
258262
return PyModuleDef_Init(&pandas_datetimemodule);
259263
}

pandas/_libs/src/vendored/numpy/datetime/np_datetime.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@ This file is derived from NumPy 1.7. See NUMPY_LICENSE.txt
1616

1717
// Licence at LICENSES/NUMPY_LICENSE
1818

19-
#define NO_IMPORT
20-
2119
#ifndef NPY_NO_DEPRECATED_API
2220
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
2321
#endif // NPY_NO_DEPRECATED_API
2422

2523
#include <Python.h>
2624

2725
#include "pandas/vendored/numpy/datetime/np_datetime.h"
28-
#include <numpy/ndarraytypes.h>
26+
27+
#define NO_IMPORT_ARRAY
28+
#define PY_ARRAY_UNIQUE_SYMBOL PANDAS_DATETIME_NUMPY
29+
#include <numpy/ndarrayobject.h>
2930
#include <numpy/npy_common.h>
3031

3132
#if defined(_WIN32)
@@ -1070,5 +1071,8 @@ void pandas_timedelta_to_timedeltastruct(npy_timedelta td,
10701071
*/
10711072
PyArray_DatetimeMetaData
10721073
get_datetime_metadata_from_dtype(PyArray_Descr *dtype) {
1073-
return (((PyArray_DatetimeDTypeMetaData *)dtype->c_metadata)->meta);
1074+
#if NPY_ABI_VERSION < 0x02000000
1075+
#define PyDataType_C_METADATA(dtype) ((dtype)->c_metadata)
1076+
#endif
1077+
return ((PyArray_DatetimeDTypeMetaData *)PyDataType_C_METADATA(dtype))->meta;
10741078
}

pandas/_libs/tslibs/dtypes.pyx

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -273,19 +273,6 @@ cdef dict c_OFFSET_DEPR_FREQSTR = {
273273
"Y-SEP": "YE-SEP",
274274
"Y-OCT": "YE-OCT",
275275
"Y-NOV": "YE-NOV",
276-
"A": "YE",
277-
"A-DEC": "YE-DEC",
278-
"A-JAN": "YE-JAN",
279-
"A-FEB": "YE-FEB",
280-
"A-MAR": "YE-MAR",
281-
"A-APR": "YE-APR",
282-
"A-MAY": "YE-MAY",
283-
"A-JUN": "YE-JUN",
284-
"A-JUL": "YE-JUL",
285-
"A-AUG": "YE-AUG",
286-
"A-SEP": "YE-SEP",
287-
"A-OCT": "YE-OCT",
288-
"A-NOV": "YE-NOV",
289276
"BY": "BYE",
290277
"BY-DEC": "BYE-DEC",
291278
"BY-JAN": "BYE-JAN",
@@ -299,19 +286,6 @@ cdef dict c_OFFSET_DEPR_FREQSTR = {
299286
"BY-SEP": "BYE-SEP",
300287
"BY-OCT": "BYE-OCT",
301288
"BY-NOV": "BYE-NOV",
302-
"BA": "BYE",
303-
"BA-DEC": "BYE-DEC",
304-
"BA-JAN": "BYE-JAN",
305-
"BA-FEB": "BYE-FEB",
306-
"BA-MAR": "BYE-MAR",
307-
"BA-APR": "BYE-APR",
308-
"BA-MAY": "BYE-MAY",
309-
"BA-JUN": "BYE-JUN",
310-
"BA-JUL": "BYE-JUL",
311-
"BA-AUG": "BYE-AUG",
312-
"BA-SEP": "BYE-SEP",
313-
"BA-OCT": "BYE-OCT",
314-
"BA-NOV": "BYE-NOV",
315289
"BM": "BME",
316290
"CBM": "CBME",
317291
"SM": "SME",
@@ -336,59 +310,6 @@ cdef dict c_REVERSE_OFFSET_DEPR_FREQSTR = {
336310

337311
# Map deprecated resolution abbreviations to correct resolution abbreviations
338312
cdef dict c_DEPR_ABBREVS = {
339-
"A": "Y",
340-
"a": "Y",
341-
"A-DEC": "Y-DEC",
342-
"A-JAN": "Y-JAN",
343-
"A-FEB": "Y-FEB",
344-
"A-MAR": "Y-MAR",
345-
"A-APR": "Y-APR",
346-
"A-MAY": "Y-MAY",
347-
"A-JUN": "Y-JUN",
348-
"A-JUL": "Y-JUL",
349-
"A-AUG": "Y-AUG",
350-
"A-SEP": "Y-SEP",
351-
"A-OCT": "Y-OCT",
352-
"A-NOV": "Y-NOV",
353-
"BA": "BY",
354-
"BA-DEC": "BY-DEC",
355-
"BA-JAN": "BY-JAN",
356-
"BA-FEB": "BY-FEB",
357-
"BA-MAR": "BY-MAR",
358-
"BA-APR": "BY-APR",
359-
"BA-MAY": "BY-MAY",
360-
"BA-JUN": "BY-JUN",
361-
"BA-JUL": "BY-JUL",
362-
"BA-AUG": "BY-AUG",
363-
"BA-SEP": "BY-SEP",
364-
"BA-OCT": "BY-OCT",
365-
"BA-NOV": "BY-NOV",
366-
"AS": "YS",
367-
"AS-DEC": "YS-DEC",
368-
"AS-JAN": "YS-JAN",
369-
"AS-FEB": "YS-FEB",
370-
"AS-MAR": "YS-MAR",
371-
"AS-APR": "YS-APR",
372-
"AS-MAY": "YS-MAY",
373-
"AS-JUN": "YS-JUN",
374-
"AS-JUL": "YS-JUL",
375-
"AS-AUG": "YS-AUG",
376-
"AS-SEP": "YS-SEP",
377-
"AS-OCT": "YS-OCT",
378-
"AS-NOV": "YS-NOV",
379-
"BAS": "BYS",
380-
"BAS-DEC": "BYS-DEC",
381-
"BAS-JAN": "BYS-JAN",
382-
"BAS-FEB": "BYS-FEB",
383-
"BAS-MAR": "BYS-MAR",
384-
"BAS-APR": "BYS-APR",
385-
"BAS-MAY": "BYS-MAY",
386-
"BAS-JUN": "BYS-JUN",
387-
"BAS-JUL": "BYS-JUL",
388-
"BAS-AUG": "BYS-AUG",
389-
"BAS-SEP": "BYS-SEP",
390-
"BAS-OCT": "BYS-OCT",
391-
"BAS-NOV": "BYS-NOV",
392313
"H": "h",
393314
"BH": "bh",
394315
"CBH": "cbh",

pandas/_libs/tslibs/offsets.pyx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4885,14 +4885,6 @@ cpdef to_offset(freq, bint is_period=False):
48854885
f"instead of \'{name}\'"
48864886
)
48874887
elif is_period and name.upper() in c_OFFSET_DEPR_FREQSTR:
4888-
if name.upper().startswith("A"):
4889-
warnings.warn(
4890-
f"\'{name}\' is deprecated and will be removed in a future "
4891-
f"version, please use "
4892-
f"\'{c_DEPR_ABBREVS.get(name.upper())}\' instead.",
4893-
FutureWarning,
4894-
stacklevel=find_stack_level(),
4895-
)
48964888
if name.upper() != name:
48974889
warnings.warn(
48984890
f"\'{name}\' is deprecated and will be removed in "

pandas/compat/pickle_compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
# our Unpickler sub-class to override methods and some dispatcher
6565
# functions for compat and uses a non-public class of the pickle module.
6666
class Unpickler(pickle._Unpickler):
67-
def find_class(self, module, name):
67+
def find_class(self, module: str, name: str) -> Any:
6868
key = (module, name)
6969
module, name = _class_locations_map.get(key, key)
7070
return super().find_class(module, name)

0 commit comments

Comments
 (0)