Skip to content

Commit d351819

Browse files
committed
Merge branch 'main' into add-pandas-merge-how-param-validation
2 parents c44feff + d093fae commit d351819

File tree

135 files changed

+842
-431
lines changed

Some content is hidden

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

135 files changed

+842
-431
lines changed

.devcontainer.json

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// Use 'settings' to set *default* container specific settings.json values on container create.
99
// You can edit these settings after create using File > Preferences > Settings > Remote.
1010
"settings": {
11-
"terminal.integrated.shell.linux": "/bin/bash",
1211
"python.pythonPath": "/usr/local/bin/python",
1312
"python.formatting.provider": "black",
1413
"python.linting.enabled": true,

.github/actions/setup-conda/action.yml

+6
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,9 @@ runs:
1414
condarc-file: ci/.condarc
1515
cache-environment: true
1616
cache-downloads: true
17+
18+
- name: Uninstall pyarrow
19+
if: ${{ env.REMOVE_PYARROW == '1' }}
20+
run: |
21+
micromamba remove -y pyarrow
22+
shell: bash -el {0}

.github/workflows/unit-tests.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
env_file: [actions-310.yaml, actions-311.yaml, actions-312.yaml]
3030
# Prevent the include jobs from overriding other jobs
3131
pattern: [""]
32+
pandas_future_infer_string: ["0"]
3233
include:
3334
- name: "Downstream Compat"
3435
env_file: actions-311-downstream_compat.yaml
@@ -58,6 +59,9 @@ jobs:
5859
# It will be temporarily activated during tests with locale.setlocale
5960
extra_loc: "zh_CN"
6061
- name: "Future infer strings"
62+
env_file: actions-312.yaml
63+
pandas_future_infer_string: "1"
64+
- name: "Future infer strings (without pyarrow)"
6165
env_file: actions-311.yaml
6266
pandas_future_infer_string: "1"
6367
- name: "Pypy"
@@ -85,9 +89,10 @@ jobs:
8589
NPY_PROMOTION_STATE: ${{ matrix.env_file == 'actions-311-numpydev.yaml' && 'weak' || 'legacy' }}
8690
# Clipboard tests
8791
QT_QPA_PLATFORM: offscreen
92+
REMOVE_PYARROW: ${{ matrix.name == 'Future infer strings (without pyarrow)' && '1' || '0' }}
8893
concurrency:
8994
# https://github.community/t/concurrecy-not-work-for-push/183068/7
90-
group: ${{ github.event_name == 'push' && github.run_number || github.ref }}-${{ matrix.env_file }}-${{ matrix.pattern }}-${{ matrix.extra_apt || '' }}}
95+
group: ${{ github.event_name == 'push' && github.run_number || github.ref }}-${{ matrix.env_file }}-${{ matrix.pattern }}-${{ matrix.extra_apt || '' }}-${{ matrix.pandas_future_infer_string }}
9196
cancel-in-progress: true
9297

9398
services:

.gitpod.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ tasks:
1414
cp gitpod/settings.json .vscode/settings.json
1515
git fetch --tags
1616
python -m pip install -ve . --no-build-isolation --config-settings editable-verbose=true
17-
pre-commit install
17+
pre-commit install --install-hooks
1818
command: |
1919
python -m pip install -ve . --no-build-isolation --config-settings editable-verbose=true
2020
echo "✨ Pre-build complete! You can close this terminal ✨ "

Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM python:3.10.8
22
WORKDIR /home/pandas
33

44
RUN apt-get update && apt-get -y upgrade
5-
RUN apt-get install -y build-essential
5+
RUN apt-get install -y build-essential bash-completion
66

77
# hdf5 needed for pytables installation
88
# libgles2-mesa needed for pytest-qt
@@ -12,4 +12,6 @@ RUN python -m pip install --upgrade pip
1212
COPY requirements-dev.txt /tmp
1313
RUN python -m pip install -r /tmp/requirements-dev.txt
1414
RUN git config --global --add safe.directory /home/pandas
15+
16+
ENV SHELL "/bin/bash"
1517
CMD ["/bin/bash"]

ci/code_checks.sh

-6
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
7070
--format=actions \
7171
-i ES01 `# For now it is ok if docstrings are missing the extended summary` \
7272
-i "pandas.Series.dt PR01" `# Accessors are implemented as classes, but we do not document the Parameters section` \
73-
-i "pandas.MultiIndex.get_loc_level PR07" \
7473
-i "pandas.MultiIndex.names SA01" \
7574
-i "pandas.MultiIndex.reorder_levels RT03,SA01" \
7675
-i "pandas.MultiIndex.sortlevel PR07,SA01" \
@@ -164,7 +163,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
164163
-i "pandas.Series.str.center RT03,SA01" \
165164
-i "pandas.Series.str.decode PR07,RT03,SA01" \
166165
-i "pandas.Series.str.encode PR07,RT03,SA01" \
167-
-i "pandas.Series.str.index RT03" \
168166
-i "pandas.Series.str.ljust RT03,SA01" \
169167
-i "pandas.Series.str.lower RT03" \
170168
-i "pandas.Series.str.lstrip RT03" \
@@ -173,7 +171,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
173171
-i "pandas.Series.str.partition RT03" \
174172
-i "pandas.Series.str.repeat SA01" \
175173
-i "pandas.Series.str.replace SA01" \
176-
-i "pandas.Series.str.rindex RT03" \
177174
-i "pandas.Series.str.rjust RT03,SA01" \
178175
-i "pandas.Series.str.rpartition RT03" \
179176
-i "pandas.Series.str.rstrip RT03" \
@@ -284,12 +281,9 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
284281
-i "pandas.api.types.is_iterator PR07,SA01" \
285282
-i "pandas.api.types.is_list_like SA01" \
286283
-i "pandas.api.types.is_named_tuple PR07,SA01" \
287-
-i "pandas.api.types.is_numeric_dtype SA01" \
288284
-i "pandas.api.types.is_object_dtype SA01" \
289-
-i "pandas.api.types.is_period_dtype SA01" \
290285
-i "pandas.api.types.is_re PR07,SA01" \
291286
-i "pandas.api.types.is_re_compilable PR07,SA01" \
292-
-i "pandas.api.types.is_timedelta64_ns_dtype SA01" \
293287
-i "pandas.api.types.pandas_dtype PR07,RT03,SA01" \
294288
-i "pandas.arrays.ArrowExtensionArray PR07,SA01" \
295289
-i "pandas.arrays.BooleanArray SA01" \

doc/source/whatsnew/v3.0.0.rst

+3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ Other enhancements
5151
- :meth:`DataFrame.pivot_table` and :func:`pivot_table` now allow the passing of keyword arguments to ``aggfunc`` through ``**kwargs`` (:issue:`57884`)
5252
- :meth:`Series.cummin` and :meth:`Series.cummax` now supports :class:`CategoricalDtype` (:issue:`52335`)
5353
- :meth:`Series.plot` now correctly handle the ``ylabel`` parameter for pie charts, allowing for explicit control over the y-axis label (:issue:`58239`)
54+
- :meth:`pandas.concat` will raise a ``ValueError`` when ``ignore_index=True`` and ``keys`` is not ``None`` (:issue:`59274`)
55+
- Multiplying two :class:`DateOffset` objects will now raise a ``TypeError`` instead of a ``RecursionError`` (:issue:`59442`)
5456
- Restore support for reading Stata 104-format and enable reading 103-format dta files (:issue:`58554`)
5557
- Support reading Stata 102-format (Stata 1) dta files (:issue:`58978`)
5658
- Support reading Stata 110-format (Stata 7) dta files (:issue:`47176`)
@@ -618,6 +620,7 @@ Groupby/resample/rolling
618620

619621
Reshaping
620622
^^^^^^^^^
623+
- Bug in :func:`qcut` where values at the quantile boundaries could be incorrectly assigned (:issue:`59355`)
621624
- Bug in :meth:`DataFrame.join` inconsistently setting result index name (:issue:`55815`)
622625
- Bug in :meth:`DataFrame.unstack` producing incorrect results when ``sort=False`` (:issue:`54987`, :issue:`55516`)
623626
- Bug in :meth:`DataFrame.unstack` producing incorrect results when manipulating empty :class:`DataFrame` with an :class:`ExtentionDtype` (:issue:`59123`)

pandas/_libs/tslibs/offsets.pyx

+6
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,12 @@ cdef class BaseOffset:
491491
elif is_integer_object(other):
492492
return type(self)(n=other * self.n, normalize=self.normalize,
493493
**self.kwds)
494+
elif isinstance(other, BaseOffset):
495+
# Otherwise raises RecurrsionError due to __rmul__
496+
raise TypeError(
497+
f"Cannot multiply {type(self).__name__} with "
498+
f"{type(other).__name__}."
499+
)
494500
return NotImplemented
495501

496502
def __rmul__(self, other):

pandas/_testing/__init__.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import numpy as np
1414

15+
from pandas._config import using_string_dtype
1516
from pandas._config.localization import (
1617
can_set_locale,
1718
get_locales,
@@ -106,7 +107,10 @@
106107
ALL_FLOAT_DTYPES: list[Dtype] = [*FLOAT_NUMPY_DTYPES, *FLOAT_EA_DTYPES]
107108

108109
COMPLEX_DTYPES: list[Dtype] = [complex, "complex64", "complex128"]
109-
STRING_DTYPES: list[Dtype] = [str, "str", "U"]
110+
if using_string_dtype():
111+
STRING_DTYPES: list[Dtype] = [str, "U"]
112+
else:
113+
STRING_DTYPES: list[Dtype] = [str, "str", "U"] # type: ignore[no-redef]
110114
COMPLEX_FLOAT_DTYPES: list[Dtype] = [*COMPLEX_DTYPES, *FLOAT_NUMPY_DTYPES]
111115

112116
DATETIME64_DTYPES: list[Dtype] = ["datetime64[ns]", "M8[ns]"]

pandas/core/array_algos/quantile.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ def quantile_with_mask(
9494
flat = np.array([fill_value] * len(qs))
9595
result = np.repeat(flat, len(values)).reshape(len(values), len(qs))
9696
else:
97-
result = _nanpercentile(
97+
result = _nanquantile(
9898
values,
99-
qs * 100.0,
99+
qs,
100100
na_value=fill_value,
101101
mask=mask,
102102
interpolation=interpolation,
@@ -108,15 +108,15 @@ def quantile_with_mask(
108108
return result
109109

110110

111-
def _nanpercentile_1d(
111+
def _nanquantile_1d(
112112
values: np.ndarray,
113113
mask: npt.NDArray[np.bool_],
114114
qs: npt.NDArray[np.float64],
115115
na_value: Scalar,
116116
interpolation: str,
117117
) -> Scalar | np.ndarray:
118118
"""
119-
Wrapper for np.percentile that skips missing values, specialized to
119+
Wrapper for np.quantile that skips missing values, specialized to
120120
1-dimensional case.
121121
122122
Parameters
@@ -142,7 +142,7 @@ def _nanpercentile_1d(
142142
# equiv: 'np.array([na_value] * len(qs))' but much faster
143143
return np.full(len(qs), na_value)
144144

145-
return np.percentile(
145+
return np.quantile(
146146
values,
147147
qs,
148148
# error: No overload variant of "percentile" matches argument
@@ -152,7 +152,7 @@ def _nanpercentile_1d(
152152
)
153153

154154

155-
def _nanpercentile(
155+
def _nanquantile(
156156
values: np.ndarray,
157157
qs: npt.NDArray[np.float64],
158158
*,
@@ -161,7 +161,7 @@ def _nanpercentile(
161161
interpolation: str,
162162
):
163163
"""
164-
Wrapper for np.percentile that skips missing values.
164+
Wrapper for np.quantile that skips missing values.
165165
166166
Parameters
167167
----------
@@ -180,7 +180,7 @@ def _nanpercentile(
180180

181181
if values.dtype.kind in "mM":
182182
# need to cast to integer to avoid rounding errors in numpy
183-
result = _nanpercentile(
183+
result = _nanquantile(
184184
values.view("i8"),
185185
qs=qs,
186186
na_value=na_value.view("i8"),
@@ -196,7 +196,7 @@ def _nanpercentile(
196196
# Caller is responsible for ensuring mask shape match
197197
assert mask.shape == values.shape
198198
result = [
199-
_nanpercentile_1d(val, m, qs, na_value, interpolation=interpolation)
199+
_nanquantile_1d(val, m, qs, na_value, interpolation=interpolation)
200200
for (val, m) in zip(list(values), list(mask))
201201
]
202202
if values.dtype.kind == "f":
@@ -215,7 +215,7 @@ def _nanpercentile(
215215
result = result.astype(values.dtype, copy=False)
216216
return result
217217
else:
218-
return np.percentile(
218+
return np.quantile(
219219
values,
220220
qs,
221221
axis=1,

pandas/core/arrays/arrow/array.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,10 @@ def __getitem__(self, item: PositionalIndexer):
575575
if isinstance(item, np.ndarray):
576576
if not len(item):
577577
# Removable once we migrate StringDtype[pyarrow] to ArrowDtype[string]
578-
if self._dtype.name == "string" and self._dtype.storage == "pyarrow":
578+
if (
579+
isinstance(self._dtype, StringDtype)
580+
and self._dtype.storage == "pyarrow"
581+
):
579582
# TODO(infer_string) should this be large_string?
580583
pa_dtype = pa.string()
581584
else:

0 commit comments

Comments
 (0)