Skip to content

Commit f15701b

Browse files
Merge remote-tracking branch 'upstream/master' into bisect
2 parents f064d50 + 18b4864 commit f15701b

File tree

434 files changed

+19575
-17530
lines changed

Some content is hidden

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

434 files changed

+19575
-17530
lines changed

.github/workflows/ci.yml

-6
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ jobs:
3737
ci/code_checks.sh lint
3838
if: always()
3939

40-
- name: Dependencies consistency
41-
run: |
42-
source activate pandas-dev
43-
ci/code_checks.sh dependencies
44-
if: always()
45-
4640
- name: Checks on imported code
4741
run: |
4842
source activate pandas-dev

.pre-commit-config.yaml

+65-10
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,23 @@ repos:
99
- id: flake8
1010
additional_dependencies: [flake8-comprehensions>=3.1.0]
1111
- id: flake8
12-
name: flake8-pyx
13-
files: \.(pyx|pxd)$
14-
types:
15-
- file
12+
name: flake8 (cython)
13+
types: [cython]
1614
args: [--append-config=flake8/cython.cfg]
1715
- id: flake8
18-
name: flake8-pxd
16+
name: flake8 (cython template)
1917
files: \.pxi\.in$
2018
types:
2119
- file
2220
args: [--append-config=flake8/cython-template.cfg]
2321
- repo: https://github.com/PyCQA/isort
24-
rev: 5.6.0
22+
rev: 5.6.3
2523
hooks:
2624
- id: isort
27-
exclude: ^pandas/__init__\.py$|^pandas/core/api\.py$
28-
files: '.pxd$|.py$'
29-
types: [file]
25+
name: isort (python)
26+
- id: isort
27+
name: isort (cython)
28+
types: [cython]
3029
- repo: https://github.com/asottile/pyupgrade
3130
rev: v2.7.2
3231
hooks:
@@ -46,6 +45,60 @@ repos:
4645
files: ^(environment.yml|requirements-dev.txt)$
4746
pass_filenames: false
4847
additional_dependencies: [pyyaml]
48+
- id: flake8-rst
49+
name: flake8-rst
50+
description: Run flake8 on code snippets in docstrings or RST files
51+
language: python
52+
entry: flake8-rst
53+
types: [rst]
54+
args: [--filename=*.rst]
55+
additional_dependencies: [flake8-rst==0.7.0, flake8==3.7.9]
56+
- id: incorrect-sphinx-directives
57+
name: Check for incorrect Sphinx directives
58+
language: pygrep
59+
entry: |
60+
(?x)
61+
# Check for cases of e.g. .. warning: instead of .. warning::
62+
\.\.\ (
63+
autosummary|contents|currentmodule|deprecated|
64+
function|image|important|include|ipython|literalinclude|
65+
math|module|note|raw|seealso|toctree|versionadded|
66+
versionchanged|warning
67+
):[^:]
68+
files: \.(py|pyx|rst)$
69+
- id: non-standard-imports
70+
name: Check for non-standard imports
71+
language: pygrep
72+
entry: |
73+
(?x)
74+
# Check for imports from pandas.core.common instead of `import pandas.core.common as com`
75+
from\ pandas\.core\.common\ import|
76+
from\ pandas\.core\ import\ common|
77+
78+
# Check for imports from collections.abc instead of `from collections import abc`
79+
from\ collections\.abc\ import|
80+
81+
from\ numpy\ import\ nan
82+
types: [python]
83+
- id: non-standard-imports-in-tests
84+
name: Check for non-standard imports in test suite
85+
language: pygrep
86+
entry: |
87+
(?x)
88+
# Check for imports from pandas._testing instead of `import pandas._testing as tm`
89+
from\ pandas\._testing\ import|
90+
from\ pandas\ import\ _testing\ as\ tm|
91+
92+
# No direct imports from conftest
93+
conftest\ import|
94+
import\ conftest
95+
types: [python]
96+
files: ^pandas/tests/
97+
- id: incorrect-code-directives
98+
name: Check for incorrect code block or IPython directives
99+
language: pygrep
100+
entry: (\.\. code-block ::|\.\. ipython ::)
101+
files: \.(py|pyx|rst)$
49102
- repo: https://github.com/asottile/yesqa
50103
rev: v1.2.2
51104
hooks:
@@ -54,4 +107,6 @@ repos:
54107
rev: v3.2.0
55108
hooks:
56109
- id: end-of-file-fixer
57-
exclude: '.html$|^LICENSES/|.csv$|.txt$|.svg$|.py$'
110+
exclude: ^LICENSES/|\.(html|csv|txt|svg|py)$
111+
- id: trailing-whitespace
112+
exclude: \.(html|svg)$

asv_bench/benchmarks/groupby.py

+20
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,26 @@ def time_category_size(self):
358358
self.draws.groupby(self.cats).size()
359359

360360

361+
class FillNA:
362+
def setup(self):
363+
N = 100
364+
self.df = DataFrame(
365+
{"group": [1] * N + [2] * N, "value": [np.nan, 1.0] * N}
366+
).set_index("group")
367+
368+
def time_df_ffill(self):
369+
self.df.groupby("group").fillna(method="ffill")
370+
371+
def time_df_bfill(self):
372+
self.df.groupby("group").fillna(method="bfill")
373+
374+
def time_srs_ffill(self):
375+
self.df.groupby("group")["value"].fillna(method="ffill")
376+
377+
def time_srs_bfill(self):
378+
self.df.groupby("group")["value"].fillna(method="bfill")
379+
380+
361381
class GroupByMethods:
362382

363383
param_names = ["dtype", "method", "application"]

asv_bench/benchmarks/io/pickle.py

+6
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,11 @@ def time_read_pickle(self):
2424
def time_write_pickle(self):
2525
self.df.to_pickle(self.fname)
2626

27+
def peakmem_read_pickle(self):
28+
read_pickle(self.fname)
29+
30+
def peakmem_write_pickle(self):
31+
self.df.to_pickle(self.fname)
32+
2733

2834
from ..pandas_vb_common import setup # noqa: F401 isort:skip

asv_bench/benchmarks/rolling.py

+9
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,21 @@ class ExpandingMethods:
7676

7777
def setup(self, constructor, dtype, method):
7878
N = 10 ** 5
79+
N_groupby = 100
7980
arr = (100 * np.random.random(N)).astype(dtype)
8081
self.expanding = getattr(pd, constructor)(arr).expanding()
82+
self.expanding_groupby = (
83+
pd.DataFrame({"A": arr[:N_groupby], "B": range(N_groupby)})
84+
.groupby("B")
85+
.expanding()
86+
)
8187

8288
def time_expanding(self, constructor, dtype, method):
8389
getattr(self.expanding, method)()
8490

91+
def time_expanding_groupby(self, constructor, dtype, method):
92+
getattr(self.expanding_groupby, method)()
93+
8594

8695
class EWMMethods:
8796

asv_bench/benchmarks/timeseries.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33
import dateutil
44
import numpy as np
55

6-
from pandas import DataFrame, Series, date_range, period_range, to_datetime
6+
from pandas import (
7+
DataFrame,
8+
Series,
9+
date_range,
10+
period_range,
11+
timedelta_range,
12+
to_datetime,
13+
)
714

815
from pandas.tseries.frequencies import infer_freq
916

@@ -121,12 +128,15 @@ def time_convert(self):
121128

122129
class Iteration:
123130

124-
params = [date_range, period_range]
131+
params = [date_range, period_range, timedelta_range]
125132
param_names = ["time_index"]
126133

127134
def setup(self, time_index):
128135
N = 10 ** 6
129-
self.idx = time_index(start="20140101", freq="T", periods=N)
136+
if time_index is timedelta_range:
137+
self.idx = time_index(start=0, freq="T", periods=N)
138+
else:
139+
self.idx = time_index(start="20140101", freq="T", periods=N)
130140
self.exit = 10000
131141

132142
def time_iter(self, time_index):

0 commit comments

Comments
 (0)