Skip to content

Commit e08f4e0

Browse files
authored
Merge branch 'main' into dev/depr/literal-str-read_xml
2 parents 2c58638 + 76541f5 commit e08f4e0

Some content is hidden

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

59 files changed

+1720
-569
lines changed

.github/actions/build_pandas/action.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ runs:
1414
micromamba list
1515
shell: bash -el {0}
1616

17+
- name: Uninstall existing Pandas installation
18+
run: |
19+
if pip list | grep -q ^pandas; then
20+
pip uninstall -y pandas || true
21+
fi
22+
shell: bash -el {0}
23+
1724
- name: Build Pandas
1825
run: |
1926
if [[ ${{ inputs.editable }} == "true" ]]; then

.github/workflows/unit-tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ jobs:
8181
ENV_FILE: ci/deps/${{ matrix.env_file }}
8282
PATTERN: ${{ matrix.pattern }}
8383
EXTRA_APT: ${{ matrix.extra_apt || '' }}
84-
LANG: ${{ matrix.lang || '' }}
84+
LANG: ${{ matrix.lang || 'C.UTF-8' }}
8585
LC_ALL: ${{ matrix.lc_all || '' }}
8686
PANDAS_COPY_ON_WRITE: ${{ matrix.pandas_copy_on_write || '0' }}
8787
PANDAS_CI: ${{ matrix.pandas_ci || '1' }}
@@ -122,7 +122,7 @@ jobs:
122122
- 5432:5432
123123

124124
moto:
125-
image: motoserver/moto:4.1.4
125+
image: motoserver/moto:4.1.12
126126
env:
127127
AWS_ACCESS_KEY_ID: foobar_key
128128
AWS_SECRET_ACCESS_KEY: foobar_secret
@@ -227,7 +227,7 @@ jobs:
227227
fi
228228
- name: Build environment and Run Tests
229229
run: |
230-
/opt/python/cp39-cp39/bin/python -m venv ~/virtualenvs/pandas-dev
230+
/opt/python/cp311-cp311/bin/python -m venv ~/virtualenvs/pandas-dev
231231
. ~/virtualenvs/pandas-dev/bin/activate
232232
python -m pip install -U pip wheel setuptools meson[ninja]==1.0.1 meson-python==0.13.1
233233
python -m pip install --no-cache-dir versioneer[toml] cython numpy python-dateutil pytz pytest>=7.3.2 pytest-xdist>=2.2.0 pytest-asyncio>=0.17 hypothesis>=6.46.1
@@ -265,7 +265,7 @@ jobs:
265265
apk add musl-locales
266266
- name: Build environment
267267
run: |
268-
/opt/python/cp39-cp39/bin/python -m venv ~/virtualenvs/pandas-dev
268+
/opt/python/cp311-cp311/bin/python -m venv ~/virtualenvs/pandas-dev
269269
. ~/virtualenvs/pandas-dev/bin/activate
270270
python -m pip install -U pip wheel setuptools meson-python==0.13.1 meson[ninja]==1.0.1
271271
python -m pip install --no-cache-dir versioneer[toml] cython numpy python-dateutil pytz pytest>=7.3.2 pytest-xdist>=2.2.0 pytest-asyncio>=0.17 hypothesis>=6.46.1

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,11 @@ repos:
339339
language: python
340340
entry: python scripts/validate_unwanted_patterns.py --validation-type="strings_with_wrong_placed_whitespace"
341341
types_or: [python, cython]
342+
- id: unwanted-patterns-nodefault-used-not-only-for-typing
343+
name: Check that `pandas._libs.lib.NoDefault` is used only for typing
344+
language: python
345+
entry: python scripts/validate_unwanted_patterns.py --validation-type="nodefault_used_not_only_for_typing"
346+
types: [python]
342347
- id: use-pd_array-in-core
343348
name: Import pandas.array as pd_array in core
344349
language: python

ci/code_checks.sh

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,6 @@ BASE_DIR="$(dirname $0)/.."
2121
RET=0
2222
CHECK=$1
2323

24-
function invgrep {
25-
# grep with inverse exist status and formatting for azure-pipelines
26-
#
27-
# This function works exactly as grep, but with opposite exit status:
28-
# - 0 (success) when no patterns are found
29-
# - 1 (fail) when the patterns are found
30-
#
31-
# This is useful for the CI, as we want to fail if one of the patterns
32-
# that we want to avoid is found by grep.
33-
grep -n "$@" | sed "s/^/$INVGREP_PREPEND/" | sed "s/$/$INVGREP_APPEND/" ; EXIT_STATUS=${PIPESTATUS[0]}
34-
return $((! $EXIT_STATUS))
35-
}
36-
37-
if [[ "$GITHUB_ACTIONS" == "true" ]]; then
38-
INVGREP_PREPEND="##[error]"
39-
fi
40-
4124
### CODE ###
4225
if [[ -z "$CHECK" || "$CHECK" == "code" ]]; then
4326

@@ -118,25 +101,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
118101
pandas.io.stata.StataReader.value_labels \
119102
pandas.io.stata.StataReader.variable_labels \
120103
pandas.io.stata.StataWriter.write_file \
121-
pandas.core.resample.Resampler.asfreq \
122-
pandas.core.resample.Resampler.count \
123-
pandas.core.resample.Resampler.nunique \
124-
pandas.core.resample.Resampler.max \
125-
pandas.core.resample.Resampler.mean \
126-
pandas.core.resample.Resampler.median \
127-
pandas.core.resample.Resampler.min \
128-
pandas.core.resample.Resampler.ohlc \
129-
pandas.core.resample.Resampler.prod \
130-
pandas.core.resample.Resampler.size \
131-
pandas.core.resample.Resampler.sem \
132-
pandas.core.resample.Resampler.std \
133-
pandas.core.resample.Resampler.sum \
134-
pandas.core.resample.Resampler.var \
135-
pandas.core.resample.Resampler.quantile \
136-
pandas.describe_option \
137-
pandas.reset_option \
138-
pandas.get_option \
139-
pandas.set_option \
140104
pandas.plotting.deregister_matplotlib_converters \
141105
pandas.plotting.plot_params \
142106
pandas.plotting.register_matplotlib_converters \
@@ -145,32 +109,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
145109
pandas.util.hash_pandas_object \
146110
pandas_object \
147111
pandas.api.interchange.from_dataframe \
148-
pandas.Index.asof_locs \
149-
pandas.Index.get_slice_bound \
150-
pandas.RangeIndex \
151-
pandas.RangeIndex.start \
152-
pandas.RangeIndex.stop \
153-
pandas.RangeIndex.step \
154-
pandas.RangeIndex.from_range \
155-
pandas.CategoricalIndex.codes \
156-
pandas.CategoricalIndex.categories \
157-
pandas.CategoricalIndex.ordered \
158-
pandas.CategoricalIndex.reorder_categories \
159-
pandas.CategoricalIndex.set_categories \
160-
pandas.CategoricalIndex.as_ordered \
161-
pandas.CategoricalIndex.as_unordered \
162-
pandas.CategoricalIndex.equals \
163-
pandas.IntervalIndex.values \
164-
pandas.IntervalIndex.to_tuples \
165-
pandas.MultiIndex.dtypes \
166-
pandas.MultiIndex.drop \
167112
pandas.DatetimeIndex.snap \
168-
pandas.DatetimeIndex.as_unit \
169-
pandas.DatetimeIndex.to_pydatetime \
170-
pandas.DatetimeIndex.to_series \
171-
pandas.DatetimeIndex.mean \
172-
pandas.DatetimeIndex.std \
173-
pandas.TimedeltaIndex \
174113
pandas.core.window.rolling.Rolling.max \
175114
pandas.core.window.rolling.Rolling.cov \
176115
pandas.core.window.rolling.Rolling.skew \

ci/run_tests.sh

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,9 @@ export PYTHONHASHSEED=$(python -c 'import random; print(random.randint(1, 429496
88
# May help reproduce flaky CI builds if set in subsequent runs
99
echo PYTHONHASHSEED=$PYTHONHASHSEED
1010

11-
if [[ "not network" == *"$PATTERN"* ]]; then
12-
export http_proxy=http://1.2.3.4 https_proxy=http://1.2.3.4;
13-
fi
14-
1511
COVERAGE="-s --cov=pandas --cov-report=xml --cov-append --cov-config=pyproject.toml"
1612

17-
# If no X server is found, we use xvfb to emulate it
18-
if [[ $(uname) == "Linux" && -z $DISPLAY ]]; then
19-
export DISPLAY=":0"
20-
XVFB="xvfb-run "
21-
fi
22-
23-
PYTEST_CMD="MESONPY_EDITABLE_VERBOSE=1 ${XVFB}pytest -r fEs -n $PYTEST_WORKERS --dist=loadfile $TEST_ARGS $COVERAGE $PYTEST_TARGET"
13+
PYTEST_CMD="MESONPY_EDITABLE_VERBOSE=1 pytest -r fEs -n $PYTEST_WORKERS --dist=loadfile $TEST_ARGS $COVERAGE $PYTEST_TARGET"
2414

2515
if [[ "$PATTERN" ]]; then
2616
PYTEST_CMD="$PYTEST_CMD -m \"$PATTERN\""

doc/source/user_guide/copy_on_write.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ following methods:
211211
- :meth:`DataFrame.astype` / :meth:`Series.astype`
212212
- :meth:`DataFrame.convert_dtypes` / :meth:`Series.convert_dtypes`
213213
- :meth:`DataFrame.join`
214+
- :meth:`DataFrame.eval`
214215
- :func:`concat`
215216
- :func:`merge`
216217

doc/source/whatsnew/v2.0.3.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ Fixed regressions
1616
- Bug in :meth:`Timestamp.weekday`` was returning incorrect results before ``'0000-02-29'`` (:issue:`53738`)
1717
- Fixed performance regression in merging on datetime-like columns (:issue:`53231`)
1818
- Fixed regression when :meth:`DataFrame.to_string` creates extra space for string dtypes (:issue:`52690`)
19-
- For external ExtensionArray implementations, restored the default use of ``_values_for_factorize`` for hashing arrays (:issue:`53475`)
2019

2120
.. ---------------------------------------------------------------------------
2221
.. _whatsnew_203.bug_fixes:

doc/source/whatsnew/v2.1.0.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Copy-on-Write improvements
2525
- The :class:`DataFrame` constructor, when constructing a DataFrame from a dictionary
2626
of Index objects and specifying ``copy=False``, will now use a lazy copy
2727
of those Index objects for the columns of the DataFrame (:issue:`52947`)
28+
- Add lazy copy mechanism to :meth:`DataFrame.eval` (:issue:`53746`)
2829

2930
.. _whatsnew_210.enhancements.enhancement2:
3031

@@ -112,7 +113,7 @@ Other enhancements
112113
- :meth:`SeriesGroupby.transform` and :meth:`DataFrameGroupby.transform` now support passing in a string as the function for ``engine="numba"`` (:issue:`53579`)
113114
- Added :meth:`ExtensionArray.interpolate` used by :meth:`Series.interpolate` and :meth:`DataFrame.interpolate` (:issue:`53659`)
114115
- Added ``engine_kwargs`` parameter to :meth:`DataFrame.to_excel` (:issue:`53220`)
115-
- Added a new parameter ``by_row`` to :meth:`Series.apply`. When set to ``False`` the supplied callables will always operate on the whole Series (:issue:`53400`).
116+
- Added a new parameter ``by_row`` to :meth:`Series.apply` and :meth:`DataFrame.apply`. When set to ``False`` the supplied callables will always operate on the whole Series or DataFrame (:issue:`53400`, :issue:`53601`).
116117
- Groupby aggregations (such as :meth:`DataFrameGroupby.sum`) now can preserve the dtype of the input instead of casting to ``float64`` (:issue:`44952`)
117118
- Improved error message when :meth:`DataFrameGroupBy.agg` failed (:issue:`52930`)
118119
- Many read/to_* functions, such as :meth:`DataFrame.to_pickle` and :func:`read_csv`, support forwarding compression arguments to lzma.LZMAFile (:issue:`52979`)

pandas/_config/config.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,11 @@ def __doc__(self) -> str: # type: ignore[override]
300300
The available options with its descriptions:
301301
302302
{opts_desc}
303+
304+
Examples
305+
--------
306+
>>> pd.get_option('display.max_columns') # doctest: +SKIP
307+
4
303308
"""
304309

305310
_set_option_tmpl = """
@@ -336,6 +341,17 @@ def __doc__(self) -> str: # type: ignore[override]
336341
The available options with its descriptions:
337342
338343
{opts_desc}
344+
345+
Examples
346+
--------
347+
>>> pd.set_option('display.max_columns', 4)
348+
>>> df = pd.DataFrame([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]])
349+
>>> df
350+
0 1 ... 3 4
351+
0 1 2 ... 4 5
352+
1 6 7 ... 9 10
353+
[2 rows x 5 columns]
354+
>>> pd.reset_option('display.max_columns')
339355
"""
340356

341357
_describe_option_tmpl = """
@@ -370,6 +386,12 @@ def __doc__(self) -> str: # type: ignore[override]
370386
The available options with its descriptions:
371387
372388
{opts_desc}
389+
390+
Examples
391+
--------
392+
>>> pd.describe_option('display.max_columns') # doctest: +SKIP
393+
display.max_columns : int
394+
If max_cols is exceeded, switch to truncate view...
373395
"""
374396

375397
_reset_option_tmpl = """
@@ -402,6 +424,10 @@ def __doc__(self) -> str: # type: ignore[override]
402424
The available options with its descriptions:
403425
404426
{opts_desc}
427+
428+
Examples
429+
--------
430+
>>> pd.reset_option('display.max_columns') # doctest: +SKIP
405431
"""
406432

407433
# bind the functions with their docstrings into a Callable

pandas/_libs/lib.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ NoDefault = Literal[_NoDefault.no_default]
3636
i8max: int
3737
u8max: int
3838

39-
def is_np_dtype(dtype: object, kinds: str | None = ...) -> bool: ...
39+
def is_np_dtype(dtype: object, kinds: str | None = ...) -> TypeGuard[np.dtype]: ...
4040
def item_from_zerodim(val: object) -> object: ...
4141
def infer_dtype(value: object, skipna: bool = ...) -> str: ...
4242
def is_iterator(obj: object) -> bool: ...

pandas/_testing/_io.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import bz2
44
import gzip
55
import io
6+
import pathlib
67
import tarfile
78
from typing import (
89
TYPE_CHECKING,
@@ -77,14 +78,12 @@ def round_trip_pathlib(writer, reader, path: str | None = None):
7778
pandas object
7879
The original object that was serialized and then re-read.
7980
"""
80-
import pytest
81-
82-
Path = pytest.importorskip("pathlib").Path
81+
Path = pathlib.Path
8382
if path is None:
8483
path = "___pathlib___"
8584
with ensure_clean(path) as path:
86-
writer(Path(path))
87-
obj = reader(Path(path))
85+
writer(Path(path)) # type: ignore[arg-type]
86+
obj = reader(Path(path)) # type: ignore[arg-type]
8887
return obj
8988

9089

0 commit comments

Comments
 (0)