Skip to content

Commit 8ed722a

Browse files
committed
Merge remote-tracking branch 'upstream/main' into pr/Anupam-USP-deprecate_stacklevel
2 parents 2b59e2b + 696e9bd commit 8ed722a

File tree

234 files changed

+4662
-1364
lines changed

Some content is hidden

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

234 files changed

+4662
-1364
lines changed

.github/PULL_REQUEST_TEMPLATE.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
- [ ] closes #xxxx (Replace xxxx with the Github issue number)
22
- [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature
33
- [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit).
4+
- [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions.
45
- [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.

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

+12-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ inputs:
33
environment-file:
44
description: Conda environment file to use.
55
default: environment.yml
6+
environment-name:
7+
description: Name to use for the Conda environment
8+
default: test
9+
python-version:
10+
description: Python version to install
11+
required: false
612
pyarrow-version:
713
description: If set, overrides the PyArrow version in the Conda environment to the given string.
814
required: false
@@ -18,10 +24,14 @@ runs:
1824
if: ${{ inputs.pyarrow-version }}
1925

2026
- name: Install ${{ inputs.environment-file }}
21-
uses: conda-incubator/setup-miniconda@v2
27+
uses: conda-incubator/setup-miniconda@v2.1.1
2228
with:
2329
environment-file: ${{ inputs.environment-file }}
30+
activate-environment: ${{ inputs.environment-name }}
31+
python-version: ${{ inputs.python-version }}
2432
channel-priority: ${{ runner.os == 'macOS' && 'flexible' || 'strict' }}
2533
channels: conda-forge
26-
mamba-version: "0.23"
34+
mamba-version: "0.24"
2735
use-mamba: true
36+
use-only-tar-bz2: true
37+
condarc-file: ci/condarc.yml

.github/workflows/asv-bot.yml

+2-6
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,8 @@ jobs:
4141

4242
# Although asv sets up its own env, deps are still needed
4343
# during discovery process
44-
- uses: conda-incubator/[email protected]
45-
with:
46-
activate-environment: pandas-dev
47-
channel-priority: strict
48-
environment-file: ${{ env.ENV_FILE }}
49-
use-only-tar-bz2: true
44+
- name: Set up Conda
45+
uses: ./.github/actions/setup-conda
5046

5147
- name: Run benchmarks
5248
id: bench

.github/workflows/code-checks.yml

+4-16
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,8 @@ jobs:
5858
path: ~/conda_pkgs_dir
5959
key: ${{ runner.os }}-conda-${{ hashFiles('${{ env.ENV_FILE }}') }}
6060

61-
- uses: conda-incubator/[email protected]
62-
with:
63-
mamba-version: "*"
64-
channels: conda-forge
65-
activate-environment: pandas-dev
66-
channel-priority: strict
67-
environment-file: ${{ env.ENV_FILE }}
68-
use-only-tar-bz2: true
61+
- name: Set up Conda
62+
uses: ./.github/actions/setup-conda
6963

7064
- name: Build Pandas
7165
id: build
@@ -127,14 +121,8 @@ jobs:
127121
path: ~/conda_pkgs_dir
128122
key: ${{ runner.os }}-conda-${{ hashFiles('${{ env.ENV_FILE }}') }}
129123

130-
- uses: conda-incubator/[email protected]
131-
with:
132-
mamba-version: "*"
133-
channels: conda-forge
134-
activate-environment: pandas-dev
135-
channel-priority: strict
136-
environment-file: ${{ env.ENV_FILE }}
137-
use-only-tar-bz2: true
124+
- name: Set up Conda
125+
uses: ./.github/actions/setup-conda
138126

139127
- name: Build Pandas
140128
id: build

.github/workflows/posix.yml

+3-10
Original file line numberDiff line numberDiff line change
@@ -147,18 +147,11 @@ jobs:
147147
# xsel for clipboard tests
148148
run: sudo apt-get update && sudo apt-get install -y libc6-dev-i386 xsel ${{ env.EXTRA_APT }}
149149

150-
- uses: conda-incubator/[email protected]
150+
- name: Set up Conda
151+
uses: ./.github/actions/setup-conda
151152
with:
152-
mamba-version: "*"
153-
channels: conda-forge
154-
activate-environment: pandas-dev
155-
channel-priority: flexible
156153
environment-file: ${{ env.ENV_FILE }}
157-
use-only-tar-bz2: true
158-
159-
- name: Upgrade Arrow version
160-
run: conda install -n pandas-dev -c conda-forge --no-update-deps pyarrow=${{ matrix.pyarrow_version }}
161-
if: ${{ matrix.pyarrow_version }}
154+
pyarrow-version: ${{ matrix.pyarrow_version }}
162155

163156
- name: Build Pandas
164157
uses: ./.github/actions/build_pandas

.github/workflows/sdist.yml

+7-6
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,12 @@ jobs:
5959
name: ${{matrix.python-version}}-sdist.gz
6060
path: dist/*.gz
6161

62-
- uses: conda-incubator/[email protected]
62+
- name: Set up Conda
63+
uses: ./.github/actions/setup-conda
6364
with:
64-
activate-environment: pandas-sdist
65-
channels: conda-forge
66-
python-version: '${{ matrix.python-version }}'
65+
environment-file: ""
66+
environment-name: pandas-sdist
67+
python-version: ${{ matrix.python-version }}
6768

6869
- name: Install pandas from sdist
6970
run: |
@@ -74,9 +75,9 @@ jobs:
7475
run: |
7576
case "${{matrix.python-version}}" in
7677
3.8)
77-
pip install numpy==1.18.5 ;;
78+
pip install numpy==1.19.5 ;;
7879
3.9)
79-
pip install numpy==1.19.3 ;;
80+
pip install numpy==1.19.5 ;;
8081
3.10)
8182
pip install numpy==1.21.2 ;;
8283
esac

.pre-commit-config.yaml

+13-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ repos:
2626
hooks:
2727
- id: codespell
2828
types_or: [python, rst, markdown]
29-
files: ^(pandas|doc)/
3029
- repo: https://github.com/pre-commit/pre-commit-hooks
3130
rev: v4.2.0
3231
hooks:
@@ -93,7 +92,19 @@ repos:
9392
pass_filenames: false
9493
types: [python]
9594
stages: [manual]
96-
additional_dependencies: ['[email protected]']
95+
additional_dependencies: &pyright_dependencies
96+
97+
- repo: local
98+
hooks:
99+
- id: pyright_reportGeneralTypeIssues
100+
name: pyright reportGeneralTypeIssues
101+
entry: pyright --skipunannotated -p pyright_reportGeneralTypeIssues.json
102+
# note: assumes python env is setup and activated
103+
language: node
104+
pass_filenames: false
105+
types: [python]
106+
stages: [manual]
107+
additional_dependencies: *pyright_dependencies
97108
- repo: local
98109
hooks:
99110
- id: mypy

asv_bench/benchmarks/frame_ctor.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def setup(self):
3737
self.dict_list = frame.to_dict(orient="records")
3838
self.data2 = {i: {j: float(j) for j in range(100)} for i in range(2000)}
3939

40-
# arrays which we wont consolidate
40+
# arrays which we won't consolidate
4141
self.dict_of_categoricals = {i: Categorical(np.arange(N)) for i in range(K)}
4242

4343
def time_list_of_dict(self):
@@ -60,7 +60,7 @@ def time_nested_dict_int64(self):
6060
DataFrame(self.data2)
6161

6262
def time_dict_of_categoricals(self):
63-
# dict of arrays that we wont consolidate
63+
# dict of arrays that we won't consolidate
6464
DataFrame(self.dict_of_categoricals)
6565

6666

asv_bench/benchmarks/frame_methods.py

+20
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,26 @@ def time_values_mixed_wide(self):
288288
self.df_mixed_wide.values
289289

290290

291+
class ToRecords:
292+
def setup(self):
293+
N = 100_000
294+
data = np.random.randn(N, 2)
295+
mi = MultiIndex.from_arrays(
296+
[
297+
np.arange(N),
298+
date_range("1970-01-01", periods=N, freq="ms"),
299+
]
300+
)
301+
self.df = DataFrame(data)
302+
self.df_mi = DataFrame(data, index=mi)
303+
304+
def time_to_records(self):
305+
self.df.to_records(index=True)
306+
307+
def time_to_records_multiindex(self):
308+
self.df_mi.to_records(index=True)
309+
310+
291311
class Repr:
292312
def setup(self):
293313
nrows = 10000

asv_bench/benchmarks/groupby.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ def time_dtype_as_field(self, dtype, method, application, ncols):
527527

528528
class GroupByCythonAgg:
529529
"""
530-
Benchmarks specifically targetting our cython aggregation algorithms
530+
Benchmarks specifically targeting our cython aggregation algorithms
531531
(using a big enough dataframe with simple key, so a large part of the
532532
time is actually spent in the grouped aggregation).
533533
"""

asv_bench/benchmarks/io/excel.py

+11
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,15 @@ def time_read_excel(self, engine):
8686
read_excel(fname, engine=engine)
8787

8888

89+
class ReadExcelNRows(ReadExcel):
90+
def time_read_excel(self, engine):
91+
if engine == "xlrd":
92+
fname = self.fname_excel_xls
93+
elif engine == "odf":
94+
fname = self.fname_odf
95+
else:
96+
fname = self.fname_excel
97+
read_excel(fname, engine=engine, nrows=10)
98+
99+
89100
from ..pandas_vb_common import setup # noqa: F401 isort:skip

asv_bench/benchmarks/libs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Benchmarks for code in pandas/_libs, excluding pandas/_libs/tslibs,
33
which has its own directory.
44
5-
If a PR does not edit anything in _libs/, then it is unlikely that thes
5+
If a PR does not edit anything in _libs/, then it is unlikely that the
66
benchmarks will be affected.
77
"""
88
import numpy as np

asv_bench/benchmarks/replace.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def time_replace_list(self, inplace):
5050
self.df.replace([np.inf, -np.inf], np.nan, inplace=inplace)
5151

5252
def time_replace_list_one_match(self, inplace):
53-
# the 1 can be held in self._df.blocks[0], while the inf and -inf cant
53+
# the 1 can be held in self._df.blocks[0], while the inf and -inf can't
5454
self.df.replace([np.inf, -np.inf, 1], np.nan, inplace=inplace)
5555

5656

asv_bench/benchmarks/reshape.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def time_stack(self, dtype):
7878
self.df.stack()
7979

8080
def time_unstack_fast(self, dtype):
81-
# last level -> doesnt have to make copies
81+
# last level -> doesn't have to make copies
8282
self.ser.unstack("bar")
8383

8484
def time_unstack_slow(self, dtype):

asv_bench/benchmarks/tslibs/period.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
2-
Period benchmarks that rely only on tslibs. See benchmarks.period for
3-
Period benchmarks that rely on other parts fo pandas.
2+
Period benchmarks that rely only on tslibs. See benchmarks.period for
3+
Period benchmarks that rely on other parts of pandas.
44
"""
55

66
import numpy as np

asv_bench/benchmarks/tslibs/timedelta.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
2-
Timedelta benchmarks that rely only on tslibs. See benchmarks.timedeltas for
3-
Timedelta benchmarks that rely on other parts fo pandas.
2+
Timedelta benchmarks that rely only on tslibs. See benchmarks.timedeltas for
3+
Timedelta benchmarks that rely on other parts of pandas.
44
"""
55
import datetime
66

ci/condarc.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# https://docs.conda.io/projects/conda/en/latest/configuration.html
2+
3+
# always_yes (NoneType, bool)
4+
# aliases: yes
5+
# Automatically choose the 'yes' option whenever asked to proceed with a
6+
# conda operation, such as when running `conda install`.
7+
#
8+
always_yes: true
9+
10+
# remote_connect_timeout_secs (float)
11+
# The number seconds conda will wait for your client to establish a
12+
# connection to a remote url resource.
13+
#
14+
remote_connect_timeout_secs: 30.0
15+
16+
# remote_max_retries (int)
17+
# The maximum number of retries each HTTP connection should attempt.
18+
#
19+
remote_max_retries: 10
20+
21+
# remote_backoff_factor (int)
22+
# The factor determines the time HTTP connection should wait for
23+
# attempt.
24+
#
25+
remote_backoff_factor: 3
26+
27+
# remote_read_timeout_secs (float)
28+
# Once conda has connected to a remote resource and sent an HTTP
29+
# request, the read timeout is the number of seconds conda will wait for
30+
# the server to send a response.
31+
#
32+
remote_read_timeout_secs: 60.0

0 commit comments

Comments
 (0)