Skip to content

Commit 1f35f06

Browse files
Merge remote-tracking branch 'upstream/master' into test_astype_string
2 parents d861895 + 526d52f commit 1f35f06

File tree

367 files changed

+13286
-9824
lines changed

Some content is hidden

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

367 files changed

+13286
-9824
lines changed

.pre-commit-config.yaml

Lines changed: 37 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
minimum_pre_commit_version: 2.9.2
22
exclude: ^LICENSES/|\.(html|csv|svg)$
3+
ci:
4+
autofix_prs: false
35
repos:
46
- repo: https://github.com/MarcoGorelli/absolufy-imports
57
rev: v0.3.0
@@ -36,7 +38,10 @@ repos:
3638
rev: 3.9.0
3739
hooks:
3840
- id: flake8
39-
additional_dependencies: [flake8-comprehensions>=3.1.0]
41+
additional_dependencies:
42+
- flake8-comprehensions==3.1.0
43+
- flake8-bugbear==21.3.2
44+
- pandas-dev-flaker==0.2.0
4045
- id: flake8
4146
name: flake8 (cython)
4247
types: [cython]
@@ -51,10 +56,10 @@ repos:
5156
hooks:
5257
- id: isort
5358
- repo: https://github.com/asottile/pyupgrade
54-
rev: v2.11.0
59+
rev: v2.12.0
5560
hooks:
5661
- id: pyupgrade
57-
args: [--py37-plus, --keep-runtime-typing]
62+
args: [--py37-plus]
5863
- repo: https://github.com/pre-commit/pygrep-hooks
5964
rev: v1.8.0
6065
hooks:
@@ -69,6 +74,11 @@ repos:
6974
rev: v1.2.2
7075
hooks:
7176
- id: yesqa
77+
additional_dependencies:
78+
- flake8==3.9.0
79+
- flake8-comprehensions==3.1.0
80+
- flake8-bugbear==21.3.2
81+
- pandas-dev-flaker==0.2.0
7282
- repo: local
7383
hooks:
7484
- id: flake8-rst
@@ -79,77 +89,18 @@ repos:
7989
types: [rst]
8090
args: [--filename=*.rst]
8191
additional_dependencies: [flake8-rst==0.7.0, flake8==3.7.9]
82-
- id: frame-or-series-union
83-
name: Check for use of Union[Series, DataFrame] instead of FrameOrSeriesUnion alias
84-
entry: Union\[.*(Series,.*DataFrame|DataFrame,.*Series).*\]
85-
language: pygrep
86-
types: [python]
87-
exclude: ^pandas/_typing\.py$
88-
- id: inconsistent-namespace-usage
89-
name: 'Check for inconsistent use of pandas namespace in tests'
90-
entry: python scripts/check_for_inconsistent_pandas_namespace.py
91-
language: python
92-
types: [python]
93-
files: ^pandas/tests/
94-
- id: incorrect-code-directives
95-
name: Check for incorrect code block or IPython directives
96-
language: pygrep
97-
entry: (\.\. code-block ::|\.\. ipython ::)
98-
types_or: [python, cython, rst]
99-
- id: no-os-remove
100-
name: Check code for instances of os.remove
101-
entry: os\.remove
102-
language: pygrep
103-
types: [python]
104-
files: ^pandas/tests/
105-
exclude: |
106-
(?x)^
107-
pandas/tests/io/excel/test_writers\.py
108-
|pandas/tests/io/pytables/common\.py
109-
|pandas/tests/io/pytables/test_store\.py$
110-
- id: non-standard-imports
111-
name: Check for non-standard imports
112-
language: pygrep
113-
entry: |
114-
(?x)
115-
# Check for imports from pandas.core.common instead of `import pandas.core.common as com`
116-
from\ pandas\.core\.common\ import
117-
|from\ pandas\.core\ import\ common
118-
119-
# Check for imports from collections.abc instead of `from collections import abc`
120-
|from\ collections\.abc\ import
121-
122-
# Numpy
123-
|from\ numpy\ import\ random
124-
|from\ numpy\.random\ import
125-
types: [python]
126-
- id: non-standard-imports-in-tests
127-
name: Check for non-standard imports in test suite
92+
- id: unwanted-patterns
93+
name: Unwanted patterns
12894
language: pygrep
12995
entry: |
13096
(?x)
131-
# Check for imports from pandas._testing instead of `import pandas._testing as tm`
132-
from\ pandas\._testing\ import
133-
|from\ pandas\ import\ _testing\ as\ tm
134-
135-
# No direct imports from conftest
136-
|conftest\ import
137-
|import\ conftest
138-
139-
# Check for use of pandas.testing instead of tm
140-
|pd\.testing\.
97+
# outdated annotation syntax, missing error codes
98+
\#\ type:\ (?!ignore)
99+
|\#\ type:\s?ignore(?!\[)
141100
142-
# Check for pd.api.types instead of from pandas.api.types import ...
143-
|(pd|pandas)\.api\.types\.
144-
types: [python]
145-
files: ^pandas/tests/
146-
- id: np-bool-and-np-object
147-
name: Check for use of np.bool/np.object instead of np.bool_/np.object_
148-
entry: |
149-
(?x)
150-
np\.bool[^_8]
151-
|np\.object[^_8]
152-
language: pygrep
101+
# Incorrect code-block / IPython directives
102+
|\.\.\ code-block\ ::
103+
|\.\.\ ipython\ ::
153104
types_or: [python, cython, rst]
154105
- id: pip-to-conda
155106
name: Generate pip dependency from conda
@@ -159,57 +110,28 @@ repos:
159110
files: ^(environment.yml|requirements-dev.txt)$
160111
pass_filenames: false
161112
additional_dependencies: [pyyaml]
113+
- id: sync-flake8-versions
114+
name: Check flake8 version is synced across flake8, yesqa, and environment.yml
115+
language: python
116+
entry: python scripts/sync_flake8_versions.py
117+
files: ^(\.pre-commit-config\.yaml|environment\.yml)$
118+
pass_filenames: false
119+
additional_dependencies: [pyyaml]
162120
- id: title-capitalization
163121
name: Validate correct capitalization among titles in documentation
164122
entry: python scripts/validate_rst_title_capitalization.py
165123
language: python
166124
types: [rst]
167125
files: ^doc/source/(development|reference)/
168-
- id: type-not-class
169-
name: Check for use of foo.__class__ instead of type(foo)
170-
entry: \.__class__
171-
language: pygrep
172-
types_or: [python, cython]
173-
- id: unwanted-patterns-bare-pytest-raises
174-
name: Check for use of bare pytest raises
175-
language: python
176-
entry: python scripts/validate_unwanted_patterns.py --validation-type="bare_pytest_raises"
177-
types: [python]
178-
files: ^pandas/tests/
179-
exclude: ^pandas/tests/extension/
180-
- id: unwanted-patterns-private-function-across-module
181-
name: Check for use of private functions across modules
126+
- id: use-pd_array-in-core
127+
name: Import pandas.array as pd_array in core
182128
language: python
183-
entry: python scripts/validate_unwanted_patterns.py --validation-type="private_function_across_module"
129+
entry: python scripts/use_pd_array_in_core.py
130+
files: ^pandas/core/
131+
exclude: ^pandas/core/api\.py$
184132
types: [python]
185-
exclude: ^(asv_bench|pandas/tests|doc)/
186-
- id: unwanted-patterns-private-import-across-module
187-
name: Check for import of private attributes across modules
133+
- id: no-bool-in-core-generic
134+
name: Use bool_t instead of bool in pandas/core/generic.py
135+
entry: python scripts/no_bool_in_generic.py
188136
language: python
189-
entry: python scripts/validate_unwanted_patterns.py --validation-type="private_import_across_module"
190-
types: [python]
191-
exclude: ^(asv_bench|pandas/tests|doc)/
192-
- id: unwanted-patterns-pytest-xfail
193-
name: Check for use of pytest.xfail
194-
entry: pytest\.xfail
195-
language: pygrep
196-
types: [python]
197-
files: ^pandas/tests/
198-
- id: unwanted-patterns-strings-to-concatenate
199-
name: Check for use of not concatenated strings
200-
language: python
201-
entry: python scripts/validate_unwanted_patterns.py --validation-type="strings_to_concatenate"
202-
types_or: [python, cython]
203-
- id: unwanted-patterns-strings-with-wrong-placed-whitespace
204-
name: Check for strings with wrong placed spaces
205-
language: python
206-
entry: python scripts/validate_unwanted_patterns.py --validation-type="strings_with_wrong_placed_whitespace"
207-
types_or: [python, cython]
208-
- id: unwanted-typing
209-
name: Check for outdated annotation syntax and missing error codes
210-
entry: |
211-
(?x)
212-
\#\ type:\ (?!ignore)
213-
|\#\ type:\s?ignore(?!\[)
214-
language: pygrep
215-
types: [python]
137+
files: ^pandas/core/generic\.py$

.travis.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,11 @@ matrix:
3535
fast_finish: true
3636

3737
include:
38-
- arch: arm64
38+
- arch: arm64-graviton2
39+
virt: lxd
40+
group: edge
3941
env:
40-
- JOB="3.7, arm64" PYTEST_WORKERS=1 ENV_FILE="ci/deps/travis-37-arm64.yaml" PATTERN="(not slow and not network and not clipboard and not arm_slow)"
41-
42-
allow_failures:
43-
# Moved to allowed_failures 2020-09-29 due to timeouts https://github.com/pandas-dev/pandas/issues/36719
44-
- arch: arm64
45-
env:
46-
- JOB="3.7, arm64" PYTEST_WORKERS=1 ENV_FILE="ci/deps/travis-37-arm64.yaml" PATTERN="(not slow and not network and not clipboard and not arm_slow)"
47-
42+
- JOB="3.7, arm64" PYTEST_WORKERS="auto" ENV_FILE="ci/deps/travis-37-arm64.yaml" PATTERN="(not slow and not network and not clipboard and not arm_slow)"
4843

4944
before_install:
5045
- echo "before_install"

LICENSES/PYUPGRADE_LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2017 Anthony Sottile
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ global-exclude *.h5
1717
global-exclude *.html
1818
global-exclude *.json
1919
global-exclude *.jsonl
20+
global-exclude *.pdf
2021
global-exclude *.pickle
2122
global-exclude *.png
23+
global-exclude *.pptx
2224
global-exclude *.pyc
2325
global-exclude *.pyd
2426
global-exclude *.ods

asv_bench/benchmarks/arithmetic.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,7 @@ def setup(self, op, shape):
140140
# construct dataframe with 2 blocks
141141
arr1 = np.random.randn(n_rows, n_cols // 2).astype("f8")
142142
arr2 = np.random.randn(n_rows, n_cols // 2).astype("f4")
143-
df = pd.concat(
144-
[pd.DataFrame(arr1), pd.DataFrame(arr2)], axis=1, ignore_index=True
145-
)
143+
df = pd.concat([DataFrame(arr1), DataFrame(arr2)], axis=1, ignore_index=True)
146144
# should already be the case, but just to be sure
147145
df._consolidate_inplace()
148146

@@ -151,7 +149,7 @@ def setup(self, op, shape):
151149
arr2 = np.random.randn(n_rows, n_cols // 2).astype("i8")
152150
arr3 = np.random.randn(n_rows, n_cols // 4).astype("f8")
153151
df2 = pd.concat(
154-
[pd.DataFrame(arr1), pd.DataFrame(arr2), pd.DataFrame(arr3)],
152+
[DataFrame(arr1), DataFrame(arr2), DataFrame(arr3)],
155153
axis=1,
156154
ignore_index=True,
157155
)
@@ -459,9 +457,9 @@ class OffsetArrayArithmetic:
459457

460458
def setup(self, offset):
461459
N = 10000
462-
rng = pd.date_range(start="1/1/2000", periods=N, freq="T")
460+
rng = date_range(start="1/1/2000", periods=N, freq="T")
463461
self.rng = rng
464-
self.ser = pd.Series(rng)
462+
self.ser = Series(rng)
465463

466464
def time_add_series_offset(self, offset):
467465
with warnings.catch_warnings(record=True):
@@ -478,7 +476,7 @@ class ApplyIndex:
478476

479477
def setup(self, offset):
480478
N = 10000
481-
rng = pd.date_range(start="1/1/2000", periods=N, freq="T")
479+
rng = date_range(start="1/1/2000", periods=N, freq="T")
482480
self.rng = rng
483481

484482
def time_apply_index(self, offset):
@@ -490,17 +488,17 @@ class BinaryOpsMultiIndex:
490488
param_names = ["func"]
491489

492490
def setup(self, func):
493-
date_range = pd.date_range("20200101 00:00", "20200102 0:00", freq="S")
491+
array = date_range("20200101 00:00", "20200102 0:00", freq="S")
494492
level_0_names = [str(i) for i in range(30)]
495493

496-
index = pd.MultiIndex.from_product([level_0_names, date_range])
494+
index = pd.MultiIndex.from_product([level_0_names, array])
497495
column_names = ["col_1", "col_2"]
498496

499-
self.df = pd.DataFrame(
497+
self.df = DataFrame(
500498
np.random.rand(len(index), 2), index=index, columns=column_names
501499
)
502500

503-
self.arg_df = pd.DataFrame(
501+
self.arg_df = DataFrame(
504502
np.random.randint(1, 10, (len(level_0_names), 2)),
505503
index=level_0_names,
506504
columns=column_names,

asv_bench/benchmarks/gil.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
except ImportError:
3232
from pandas import algos
3333
try:
34-
from pandas._testing import test_parallel
34+
from pandas._testing import test_parallel # noqa: PDF014
3535

3636
have_real_test_parallel = True
3737
except ImportError:

asv_bench/benchmarks/groupby.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,19 @@ class GroupByCythonAgg:
480480
param_names = ["dtype", "method"]
481481
params = [
482482
["float64"],
483-
["sum", "prod", "min", "max", "mean", "median", "var", "first", "last"],
483+
[
484+
"sum",
485+
"prod",
486+
"min",
487+
"max",
488+
"mean",
489+
"median",
490+
"var",
491+
"first",
492+
"last",
493+
"any",
494+
"all",
495+
],
484496
]
485497

486498
def setup(self, dtype, method):

asv_bench/benchmarks/pandas_vb_common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class BaseIO:
7070
def remove(self, f):
7171
"""Remove created files"""
7272
try:
73-
os.remove(f)
73+
os.remove(f) # noqa: PDF008
7474
except OSError:
7575
# On Windows, attempting to remove a file that is in use
7676
# causes an exception to be raised

asv_bench/benchmarks/sparse.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def setup(self):
2828
data = np.random.randn(N)[:-i]
2929
idx = rng[:-i]
3030
data[100:] = np.nan
31-
self.series[i] = pd.Series(pd.SparseArray(data), index=idx)
31+
self.series[i] = Series(SparseArray(data), index=idx)
3232

3333
def time_series_to_frame(self):
3434
pd.DataFrame(self.series)
@@ -63,7 +63,7 @@ def setup(self):
6363
)
6464

6565
def time_sparse_series_from_coo(self):
66-
pd.Series.sparse.from_coo(self.matrix)
66+
Series.sparse.from_coo(self.matrix)
6767

6868

6969
class ToCoo:

ci/azure/windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
vmImage: ${{ parameters.vmImage }}
99
strategy:
1010
matrix:
11-
py37_np16:
11+
py37_np17:
1212
ENV_FILE: ci/deps/azure-windows-37.yaml
1313
CONDA_PY: "37"
1414
PATTERN: "not slow and not network"

0 commit comments

Comments
 (0)