Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into sty/ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
mroeschke committed Jan 23, 2024
2 parents 359736e + 3c96b8f commit 2ea6780
Show file tree
Hide file tree
Showing 166 changed files with 1,457 additions and 834 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ jobs:
- name: "Numpy Dev"
env_file: actions-311-numpydev.yaml
pattern: "not slow and not network and not single_cpu"
test_args: "-W error::DeprecationWarning -W error::FutureWarning"
# Currently restricted the warnings that error to Deprecation Warnings from numpy
# done since pyarrow isn't compatible with numpydev always
# TODO: work with pyarrow to revert this?
test_args: "-W error::DeprecationWarning:numpy -W error::FutureWarning:numpy"
- name: "Pyarrow Nightly"
env_file: actions-311-pyarrownightly.yaml
pattern: "not slow and not network and not single_cpu"
Expand Down
5 changes: 1 addition & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ repos:
types: [python]
stages: [manual]
additional_dependencies: &pyright_dependencies
- pyright@1.1.339
- pyright@1.1.347
- id: pyright
# note: assumes python env is setup and activated
name: pyright reportGeneralTypeIssues
Expand Down Expand Up @@ -188,9 +188,6 @@ repos:
# Check for deprecated messages without sphinx directive
|(DEPRECATED|DEPRECATE|Deprecated)(:|,|\.)
# {foo!r} instead of {repr(foo)}
|!r}
# builtin filter function
|(?<!def)[\(\s]filter\(
types_or: [python, cython, rst]
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ BSD 3-Clause License
Copyright (c) 2008-2011, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
All rights reserved.

Copyright (c) 2011-2023, Open source contributors.
Copyright (c) 2011-2024, Open source contributors.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Expand Down
4 changes: 2 additions & 2 deletions asv_bench/benchmarks/algos/isin.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def setup(self, dtype):
self.series = Series(
Index([f"i-{i}" for i in range(N)], dtype=object), dtype=dtype
)
except ImportError:
raise NotImplementedError
except ImportError as err:
raise NotImplementedError from err
self.values = list(self.series[:2])

else:
Expand Down
4 changes: 2 additions & 2 deletions asv_bench/benchmarks/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ class ArrowStringArray:
def setup(self, multiple_chunks):
try:
import pyarrow as pa
except ImportError:
raise NotImplementedError
except ImportError as err:
raise NotImplementedError from err
strings = np.array([str(i) for i in range(10_000)], dtype=object)
if multiple_chunks:
chunks = [strings[i : i + 100] for i in range(0, len(strings), 100)]
Expand Down
16 changes: 11 additions & 5 deletions asv_bench/benchmarks/multiindex_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,20 @@ def time_categorical_level(self):

class Equals:
def setup(self):
idx_large_fast = RangeIndex(100000)
idx_small_slow = date_range(start="1/1/2012", periods=1)
self.mi_large_slow = MultiIndex.from_product([idx_large_fast, idx_small_slow])

self.mi = MultiIndex.from_product(
[
date_range("2000-01-01", periods=1000),
RangeIndex(1000),
]
)
self.mi_deepcopy = self.mi.copy(deep=True)
self.idx_non_object = RangeIndex(1)

def time_equals_deepcopy(self):
self.mi.equals(self.mi_deepcopy)

def time_equals_non_object_index(self):
self.mi_large_slow.equals(self.idx_non_object)
self.mi.equals(self.idx_non_object)


class SetOperations:
Expand Down
4 changes: 2 additions & 2 deletions asv_bench/benchmarks/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def setup(self, dtype):
self.s = Series(
Index([f"i-{i}" for i in range(10000)], dtype=object), dtype=dtype
)
except ImportError:
raise NotImplementedError
except ImportError as err:
raise NotImplementedError from err


class Construction:
Expand Down
153 changes: 124 additions & 29 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,37 +65,132 @@ fi
### DOCSTRINGS ###
if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then

MSG='Validate docstrings (EX01, EX04, GL01, GL02, GL03, GL04, GL05, GL06, GL07, GL09, GL10, PR03, PR04, PR05, PR06, PR08, PR09, PR10, RT01, RT02, RT04, RT05, SA02, SA03, SA04, SS01, SS02, SS03, SS04, SS05, SS06)' ; echo $MSG
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX01,EX04,GL01,GL02,GL03,GL04,GL05,GL06,GL07,GL09,GL10,PR03,PR04,PR05,PR06,PR08,PR09,PR10,RT01,RT02,RT04,RT05,SA02,SA03,SA04,SS01,SS02,SS03,SS04,SS05,SS06
MSG='Validate docstrings (EX01, EX03, EX04, GL01, GL02, GL03, GL04, GL05, GL06, GL07, GL09, GL10, PR03, PR04, PR05, PR06, PR08, PR09, PR10, RT01, RT02, RT04, RT05, SA02, SA03, SA04, SS01, SS02, SS03, SS04, SS05, SS06)' ; echo $MSG
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX01,EX03,EX04,GL01,GL02,GL03,GL04,GL05,GL06,GL07,GL09,GL10,PR03,PR04,PR05,PR06,PR08,PR09,PR10,RT01,RT02,RT04,RT05,SA02,SA03,SA04,SS01,SS02,SS03,SS04,SS05,SS06
RET=$(($RET + $?)) ; echo $MSG "DONE"

MSG='Partially validate docstrings (EX03)' ; echo $MSG
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX03 --ignore_functions \
pandas.Series.plot.line \
pandas.Series.to_sql \
pandas.errors.SettingWithCopyWarning \
pandas.errors.SpecificationError \
pandas.errors.UndefinedVariableError \
pandas.read_json \
pandas.io.formats.style.Styler.to_latex \
pandas.read_parquet \
pandas.DataFrame.to_sql \
pandas.io.formats.style.Styler.map \
pandas.io.formats.style.Styler.apply_index \
pandas.io.formats.style.Styler.map_index \
pandas.io.formats.style.Styler.format \
pandas.io.formats.style.Styler.set_tooltips \
pandas.io.formats.style.Styler.set_uuid \
pandas.io.formats.style.Styler.pipe \
pandas.io.formats.style.Styler.highlight_between \
pandas.io.formats.style.Styler.highlight_quantile \
pandas.io.formats.style.Styler.background_gradient \
pandas.io.formats.style.Styler.text_gradient \
pandas.DataFrame.values \
pandas.DataFrame.groupby \
pandas.DataFrame.sort_values \
pandas.DataFrame.plot.hexbin \
pandas.DataFrame.plot.line \
MSG='Partially validate docstrings (PR02)' ; echo $MSG
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=PR02 --ignore_functions \
pandas.io.formats.style.Styler.to_excel\
pandas.CategoricalIndex.rename_categories\
pandas.CategoricalIndex.reorder_categories\
pandas.CategoricalIndex.add_categories\
pandas.CategoricalIndex.remove_categories\
pandas.CategoricalIndex.set_categories\
pandas.IntervalIndex.set_closed\
pandas.IntervalIndex.contains\
pandas.IntervalIndex.overlaps\
pandas.IntervalIndex.to_tuples\
pandas.DatetimeIndex.round\
pandas.DatetimeIndex.floor\
pandas.DatetimeIndex.ceil\
pandas.DatetimeIndex.month_name\
pandas.DatetimeIndex.day_name\
pandas.DatetimeIndex.to_period\
pandas.DatetimeIndex.std\
pandas.TimedeltaIndex.round\
pandas.TimedeltaIndex.floor\
pandas.TimedeltaIndex.ceil\
pandas.PeriodIndex\
pandas.PeriodIndex.strftime\
pandas.Series.clip\
pandas.Series.rename_axis\
pandas.Series.interpolate\
pandas.Series.dt.to_period\
pandas.Series.dt.tz_localize\
pandas.Series.dt.tz_convert\
pandas.Series.dt.strftime\
pandas.Series.dt.round\
pandas.Series.dt.floor\
pandas.Series.dt.ceil\
pandas.Series.dt.month_name\
pandas.Series.dt.day_name\
pandas.Series.str.wrap\
pandas.Series.cat.rename_categories\
pandas.Series.cat.reorder_categories\
pandas.Series.cat.add_categories\
pandas.Series.cat.remove_categories\
pandas.Series.cat.set_categories\
pandas.Series.plot\
pandas.Series.plot.bar\
pandas.Series.plot.barh\
pandas.Series.plot.line\
pandas.Series.plot.pie\
pandas.DataFrame.clip\
pandas.DataFrame.plot\
pandas.DataFrame.plot.bar\
pandas.DataFrame.plot.barh\
pandas.DataFrame.plot.line\
pandas.DataFrame.plot.pie\
pandas.tseries.offsets.DateOffset\
pandas.tseries.offsets.BusinessDay\
pandas.tseries.offsets.BDay\
pandas.tseries.offsets.BusinessHour\
pandas.tseries.offsets.CustomBusinessDay\
pandas.tseries.offsets.CDay\
pandas.tseries.offsets.CustomBusinessHour\
pandas.tseries.offsets.MonthEnd\
pandas.tseries.offsets.MonthBegin\
pandas.tseries.offsets.BusinessMonthEnd\
pandas.tseries.offsets.BMonthEnd\
pandas.tseries.offsets.BusinessMonthBegin\
pandas.tseries.offsets.BMonthBegin\
pandas.tseries.offsets.CustomBusinessMonthEnd\
pandas.tseries.offsets.CBMonthEnd\
pandas.tseries.offsets.CustomBusinessMonthBegin\
pandas.tseries.offsets.CBMonthBegin\
pandas.tseries.offsets.SemiMonthEnd\
pandas.tseries.offsets.SemiMonthBegin\
pandas.tseries.offsets.Week\
pandas.tseries.offsets.WeekOfMonth\
pandas.tseries.offsets.LastWeekOfMonth\
pandas.tseries.offsets.BQuarterEnd\
pandas.tseries.offsets.BQuarterBegin\
pandas.tseries.offsets.QuarterEnd\
pandas.tseries.offsets.QuarterBegin\
pandas.tseries.offsets.BYearEnd\
pandas.tseries.offsets.BYearBegin\
pandas.tseries.offsets.YearEnd\
pandas.tseries.offsets.YearBegin\
pandas.tseries.offsets.FY5253\
pandas.tseries.offsets.FY5253Quarter\
pandas.tseries.offsets.Easter\
pandas.tseries.offsets.Day\
pandas.tseries.offsets.Hour\
pandas.tseries.offsets.Minute\
pandas.tseries.offsets.Second\
pandas.tseries.offsets.Milli\
pandas.tseries.offsets.Micro\
pandas.tseries.offsets.Nano\
pandas.describe_option\
pandas.reset_option\
pandas.get_option\
pandas.set_option\
pandas.Timestamp.max\
pandas.Timestamp.min\
pandas.Timestamp.resolution\
pandas.Timedelta.max\
pandas.Timedelta.min\
pandas.Timedelta.resolution\
pandas.Interval\
pandas.Grouper\
pandas.core.groupby.SeriesGroupBy.apply\
pandas.core.groupby.SeriesGroupBy.transform\
pandas.core.groupby.DataFrameGroupBy.transform\
pandas.core.groupby.DataFrameGroupBy.nth\
pandas.core.groupby.DataFrameGroupBy.rolling\
pandas.core.groupby.SeriesGroupBy.idxmax\
pandas.core.groupby.SeriesGroupBy.idxmin\
pandas.core.groupby.SeriesGroupBy.nth\
pandas.core.groupby.SeriesGroupBy.rolling\
pandas.core.groupby.DataFrameGroupBy.hist\
pandas.core.groupby.DataFrameGroupBy.plot\
pandas.core.groupby.SeriesGroupBy.plot\
pandas.read_hdf\
pandas.HDFStore.append\
pandas.core.window.rolling.Rolling.quantile\
pandas.core.window.expanding.Expanding.quantile\
pandas.api.extensions.ExtensionArray.argsort # There should be no backslash in the final line, please keep this comment in the last ignored function
RET=$(($RET + $?)) ; echo $MSG "DONE"

fi
Expand Down
2 changes: 1 addition & 1 deletion ci/deps/actions-39-minimum_versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dependencies:

# required dependencies
- python-dateutil=2.8.2
- numpy=1.22.4
- numpy=1.23.5
- pytz=2020.1

# optional dependencies
Expand Down
2 changes: 1 addition & 1 deletion ci/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ echo PYTHONHASHSEED=$PYTHONHASHSEED

COVERAGE="-s --cov=pandas --cov-report=xml --cov-append --cov-config=pyproject.toml"

PYTEST_CMD="MESONPY_EDITABLE_VERBOSE=1 PYTHONDEVMODE=1 PYTHONWARNDEFAULTENCODING=1 pytest -r fEs -n $PYTEST_WORKERS --dist=loadfile $TEST_ARGS $COVERAGE $PYTEST_TARGET"
PYTEST_CMD="MESONPY_EDITABLE_VERBOSE=1 PYTHONDEVMODE=1 PYTHONWARNDEFAULTENCODING=1 pytest -r fE -n $PYTEST_WORKERS --dist=loadfile $TEST_ARGS $COVERAGE $PYTEST_TARGET"

if [[ "$PATTERN" ]]; then
PYTEST_CMD="$PYTEST_CMD -m \"$PATTERN\""
Expand Down
6 changes: 3 additions & 3 deletions doc/scripts/eval_performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def bench_with(n, times=10, repeat=3, engine="numexpr"):
return (
np.array(
timeit(
f"df.eval(s, engine={repr(engine)})",
f"df.eval(s, engine={engine!r})",
setup=setup_common % (n, setup_with),
repeat=repeat,
number=times,
Expand All @@ -34,7 +34,7 @@ def bench_subset(n, times=20, repeat=3, engine="numexpr"):
return (
np.array(
timeit(
f"df.query(s, engine={repr(engine)})",
f"df.query(s, engine={engine!r})",
setup=setup_common % (n, setup_subset),
repeat=repeat,
number=times,
Expand All @@ -55,7 +55,7 @@ def bench(mn=3, mx=7, num=100, engines=("python", "numexpr"), verbose=False):
for engine in engines:
for i, n in enumerate(r):
if verbose & (i % 10 == 0):
print(f"engine: {repr(engine)}, i == {i:d}")
print(f"engine: {engine!r}, i == {i:d}")
ev_times = bench_with(n, times=1, repeat=1, engine=engine)
ev.loc[i, engine] = np.mean(ev_times)
qu_times = bench_subset(n, times=1, repeat=1, engine=engine)
Expand Down
4 changes: 2 additions & 2 deletions doc/source/getting_started/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Instructions for installing :ref:`from source <install.source>`,
Python version support
----------------------

Officially Python 3.9, 3.10 and 3.11.
Officially Python 3.9, 3.10, 3.11 and 3.12.

Installing pandas
-----------------
Expand Down Expand Up @@ -203,7 +203,7 @@ pandas requires the following dependencies.
================================================================ ==========================
Package Minimum supported version
================================================================ ==========================
`NumPy <https://numpy.org>`__ 1.22.4
`NumPy <https://numpy.org>`__ 1.23.5
`python-dateutil <https://dateutil.readthedocs.io/en/stable/>`__ 2.8.2
`pytz <https://pypi.org/project/pytz/>`__ 2020.1
`tzdata <https://pypi.org/project/tzdata/>`__ 2022.7
Expand Down
1 change: 1 addition & 0 deletions doc/source/reference/frame.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Conversion
DataFrame.infer_objects
DataFrame.copy
DataFrame.bool
DataFrame.to_numpy

Indexing, iteration
~~~~~~~~~~~~~~~~~~~
Expand Down
5 changes: 3 additions & 2 deletions doc/source/whatsnew/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ This is the list of changes to pandas between each release. For full details,
see the `commit logs <https://github.com/pandas-dev/pandas/commits/>`_. For install and
upgrade instructions, see :ref:`install`.

Version 2.3
Version 3.0
-----------

.. toctree::
:maxdepth: 2

v2.3.0
v3.0.0


Version 2.2
Expand All @@ -25,6 +25,7 @@ Version 2.2
.. toctree::
:maxdepth: 2

v2.2.1
v2.2.0

Version 2.1
Expand Down
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v2.1.4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ Bug fixes
Contributors
~~~~~~~~~~~~

.. contributors:: v2.1.3..v2.1.4|HEAD
.. contributors:: v2.1.3..v2.1.4
Loading

0 comments on commit 2ea6780

Please sign in to comment.