Skip to content

Commit 7ae1280

Browse files
committed
Merge remote-tracking branch 'upstream/master' into value_counts_part1
2 parents c9a4383 + 04e9e0a commit 7ae1280

File tree

282 files changed

+5305
-2471
lines changed

Some content is hidden

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

282 files changed

+5305
-2471
lines changed

.travis.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,6 @@ matrix:
5858
services:
5959
- mysql
6060
- postgresql
61-
62-
- env:
63-
- JOB="3.6, slow" ENV_FILE="ci/deps/travis-36-slow.yaml" PATTERN="slow" SQL="1"
64-
services:
65-
- mysql
66-
- postgresql
6761
allow_failures:
6862
- arch: arm64
6963
env:

LICENSES/XARRAY_LICENSE

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
Copyright 2014-2019, xarray Developers
2+
3+
--------------------------------------------------------------------------------
4+
15
Apache License
26
Version 2.0, January 2004
37
http://www.apache.org/licenses/

asv_bench/asv.conf.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"xlwt": [],
5454
"odfpy": [],
5555
"pytest": [],
56+
"jinja2": [],
5657
// If using Windows with python 2.7 and want to build using the
5758
// mingw toolchain (rather than MSVC), uncomment the following line.
5859
// "libpython": [],

asv_bench/benchmarks/io/style.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import numpy as np
2+
3+
from pandas import DataFrame
4+
5+
6+
class RenderApply:
7+
8+
params = [[12, 24, 36], [12, 120]]
9+
param_names = ["cols", "rows"]
10+
11+
def setup(self, cols, rows):
12+
self.df = DataFrame(
13+
np.random.randn(rows, cols),
14+
columns=[f"float_{i+1}" for i in range(cols)],
15+
index=[f"row_{i+1}" for i in range(rows)],
16+
)
17+
self._style_apply()
18+
19+
def time_render(self, cols, rows):
20+
self.st.render()
21+
22+
def peakmem_apply(self, cols, rows):
23+
self._style_apply()
24+
25+
def peakmem_render(self, cols, rows):
26+
self.st.render()
27+
28+
def _style_apply(self):
29+
def _apply_func(s):
30+
return [
31+
"background-color: lightcyan" if s.name == "row_1" else "" for v in s
32+
]
33+
34+
self.st = self.df.style.apply(_apply_func, axis=1)

asv_bench/benchmarks/rolling.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,18 @@ class EWMMethods:
9191
def setup(self, constructor, window, dtype, method):
9292
N = 10 ** 5
9393
arr = (100 * np.random.random(N)).astype(dtype)
94+
times = pd.date_range("1900", periods=N, freq="23s")
9495
self.ewm = getattr(pd, constructor)(arr).ewm(halflife=window)
96+
self.ewm_times = getattr(pd, constructor)(arr).ewm(
97+
halflife="1 Day", times=times
98+
)
9599

96100
def time_ewm(self, constructor, window, dtype, method):
97101
getattr(self.ewm, method)()
98102

103+
def time_ewm_times(self, constructor, window, dtype, method):
104+
self.ewm.mean()
105+
99106

100107
class VariableWindowMethods(Methods):
101108
params = (

asv_bench/benchmarks/tslibs/fields.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import numpy as np
2+
3+
from pandas._libs.tslibs.fields import (
4+
get_date_field,
5+
get_start_end_field,
6+
get_timedelta_field,
7+
)
8+
9+
from .tslib import _sizes
10+
11+
12+
class TimeGetTimedeltaField:
13+
params = [
14+
_sizes,
15+
["days", "h", "s", "seconds", "ms", "microseconds", "us", "ns", "nanoseconds"],
16+
]
17+
param_names = ["size", "field"]
18+
19+
def setup(self, size, field):
20+
arr = np.random.randint(0, 10, size=size, dtype="i8")
21+
self.i8data = arr
22+
23+
def time_get_timedelta_field(self, size, field):
24+
get_timedelta_field(self.i8data, field)
25+
26+
27+
class TimeGetDateField:
28+
params = [
29+
_sizes,
30+
[
31+
"Y",
32+
"M",
33+
"D",
34+
"h",
35+
"m",
36+
"s",
37+
"us",
38+
"ns",
39+
"doy",
40+
"dow",
41+
"woy",
42+
"q",
43+
"dim",
44+
"is_leap_year",
45+
],
46+
]
47+
param_names = ["size", "field"]
48+
49+
def setup(self, size, field):
50+
arr = np.random.randint(0, 10, size=size, dtype="i8")
51+
self.i8data = arr
52+
53+
def time_get_date_field(self, size, field):
54+
get_date_field(self.i8data, field)
55+
56+
57+
class TimeGetStartEndField:
58+
params = [
59+
_sizes,
60+
["start", "end"],
61+
["month", "quarter", "year"],
62+
["B", None, "QS"],
63+
[12, 3, 5],
64+
]
65+
param_names = ["size", "side", "period", "freqstr", "month_kw"]
66+
67+
def setup(self, size, side, period, freqstr, month_kw):
68+
arr = np.random.randint(0, 10, size=size, dtype="i8")
69+
self.i8data = arr
70+
71+
self.attrname = f"is_{period}_{side}"
72+
73+
def time_get_start_end_field(self, size, side, period, freqstr, month_kw):
74+
get_start_end_field(self.i8data, self.attrname, freqstr, month_kw=month_kw)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
try:
2+
from pandas._libs.tslibs import normalize_i8_timestamps, is_date_array_normalized
3+
except ImportError:
4+
from pandas._libs.tslibs.conversion import (
5+
normalize_i8_timestamps,
6+
is_date_array_normalized,
7+
)
8+
9+
import pandas as pd
10+
11+
from .tslib import _sizes, _tzs
12+
13+
14+
class Normalize:
15+
params = [
16+
_sizes,
17+
_tzs,
18+
]
19+
param_names = ["size", "tz"]
20+
21+
def setup(self, size, tz):
22+
# use an array that will have is_date_array_normalized give True,
23+
# so we do not short-circuit early.
24+
dti = pd.date_range("2016-01-01", periods=10, tz=tz).repeat(size // 10)
25+
self.i8data = dti.asi8
26+
27+
def time_normalize_i8_timestamps(self, size, tz):
28+
normalize_i8_timestamps(self.i8data, tz)
29+
30+
def time_is_date_array_normalized(self, size, tz):
31+
# TODO: cases with different levels of short-circuiting
32+
is_date_array_normalized(self.i8data, tz)

asv_bench/benchmarks/tslibs/period.py

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,20 @@
22
Period benchmarks that rely only on tslibs. See benchmarks.period for
33
Period benchmarks that rely on other parts fo pandas.
44
"""
5-
from pandas import Period
5+
6+
import numpy as np
7+
8+
from pandas._libs.tslibs.period import Period, periodarr_to_dt64arr
69

710
from pandas.tseries.frequencies import to_offset
811

12+
from .tslib import _sizes, _tzs
13+
14+
try:
15+
from pandas._libs.tslibs.vectorized import dt64arr_to_periodarr
16+
except ImportError:
17+
from pandas._libs.tslibs.period import dt64arr_to_periodarr
18+
919

1020
class PeriodProperties:
1121

@@ -68,3 +78,53 @@ def setup(self, freq, is_offset):
6878

6979
def time_period_constructor(self, freq, is_offset):
7080
Period("2012-06-01", freq=freq)
81+
82+
83+
_freq_ints = [
84+
1000,
85+
1011, # Annual - November End
86+
2000,
87+
2011, # Quarterly - November End
88+
3000,
89+
4000,
90+
4006, # Weekly - Saturday End
91+
5000,
92+
6000,
93+
7000,
94+
8000,
95+
9000,
96+
10000,
97+
11000,
98+
12000,
99+
]
100+
101+
102+
class TimePeriodArrToDT64Arr:
103+
params = [
104+
_sizes,
105+
_freq_ints,
106+
]
107+
param_names = ["size", "freq"]
108+
109+
def setup(self, size, freq):
110+
arr = np.arange(10, dtype="i8").repeat(size // 10)
111+
self.i8values = arr
112+
113+
def time_periodarray_to_dt64arr(self, size, freq):
114+
periodarr_to_dt64arr(self.i8values, freq)
115+
116+
117+
class TimeDT64ArrToPeriodArr:
118+
params = [
119+
_sizes,
120+
_freq_ints,
121+
_tzs,
122+
]
123+
param_names = ["size", "freq", "tz"]
124+
125+
def setup(self, size, freq, tz):
126+
arr = np.arange(10, dtype="i8").repeat(size // 10)
127+
self.i8values = arr
128+
129+
def time_dt64arr_to_periodarr(self, size, freq, tz):
130+
dt64arr_to_periodarr(self.i8values, freq, tz)

asv_bench/benchmarks/tslibs/resolution.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323
import numpy as np
2424
import pytz
2525

26-
from pandas._libs.tslibs.resolution import get_resolution
26+
try:
27+
from pandas._libs.tslibs import get_resolution
28+
except ImportError:
29+
from pandas._libs.tslibs.resolution import get_resolution
2730

2831

2932
class TimeResolution:

asv_bench/benchmarks/tslibs/tslib.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121
import numpy as np
2222
import pytz
2323

24-
from pandas._libs.tslib import ints_to_pydatetime
24+
try:
25+
from pandas._libs.tslibs import ints_to_pydatetime
26+
except ImportError:
27+
from pandas._libs.tslib import ints_to_pydatetime
2528

2629
_tzs = [
2730
None,
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import numpy as np
2+
from pytz import UTC
3+
4+
from pandas._libs.tslibs.tzconversion import tz_localize_to_utc
5+
6+
from .tslib import _sizes, _tzs
7+
8+
try:
9+
old_sig = False
10+
from pandas._libs.tslibs.tzconversion import tz_convert_from_utc
11+
except ImportError:
12+
old_sig = True
13+
from pandas._libs.tslibs.tzconversion import tz_convert as tz_convert_from_utc
14+
15+
16+
class TimeTZConvert:
17+
params = [
18+
_sizes,
19+
[x for x in _tzs if x is not None],
20+
]
21+
param_names = ["size", "tz"]
22+
23+
def setup(self, size, tz):
24+
arr = np.random.randint(0, 10, size=size, dtype="i8")
25+
self.i8data = arr
26+
27+
def time_tz_convert_from_utc(self, size, tz):
28+
# effectively:
29+
# dti = DatetimeIndex(self.i8data, tz=tz)
30+
# dti.tz_localize(None)
31+
if size >= 10 ** 6 and str(tz) == "tzlocal()":
32+
# asv fill will because each call takes 8+seconds
33+
return
34+
if old_sig:
35+
tz_convert_from_utc(self.i8data, UTC, tz)
36+
else:
37+
tz_convert_from_utc(self.i8data, tz)
38+
39+
def time_tz_localize_to_utc(self, size, tz):
40+
# effectively:
41+
# dti = DatetimeIndex(self.i8data)
42+
# dti.tz_localize(tz, ambiguous="NaT", nonexistent="NaT")
43+
tz_localize_to_utc(self.i8data, tz, ambiguous="NaT", nonexistent="NaT")

ci/azure/posix.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ jobs:
3030
LC_ALL: "zh_CN.utf8"
3131
EXTRA_APT: "language-pack-zh-hans"
3232

33+
py36_slow:
34+
ENV_FILE: ci/deps/azure-36-slow.yaml
35+
CONDA_PY: "36"
36+
PATTERN: "slow"
37+
3338
py36_locale:
3439
ENV_FILE: ci/deps/azure-36-locale.yaml
3540
CONDA_PY: "36"

ci/deps/azure-36-32bit.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ dependencies:
2323
- pip
2424
- pip:
2525
- cython>=0.29.16
26-
- pytest>=5.0.1
26+
- pytest>=5.0.1,<6.0.0rc0

ci/deps/azure-36-locale.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ dependencies:
77

88
# tools
99
- cython>=0.29.16
10-
- pytest>=5.0.1
10+
- pytest>=5.0.1,<6.0.0rc0
1111
- pytest-xdist>=1.21
1212
- pytest-asyncio
1313
- hypothesis>=3.58.0

ci/deps/azure-36-locale_slow.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ dependencies:
77

88
# tools
99
- cython>=0.29.16
10-
- pytest>=5.0.1
10+
- pytest>=5.0.1,<6.0.0rc0
1111
- pytest-xdist>=1.21
1212
- hypothesis>=3.58.0
1313
- pytest-azurepipelines

ci/deps/travis-36-slow.yaml renamed to ci/deps/azure-36-slow.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ dependencies:
77

88
# tools
99
- cython>=0.29.16
10-
- pytest>=5.0.1
10+
- pytest>=5.0.1,<6.0.0rc0
1111
- pytest-xdist>=1.21
1212
- hypothesis>=3.58.0
1313

ci/deps/azure-37-locale.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ dependencies:
66

77
# tools
88
- cython>=0.29.16
9-
- pytest>=5.0.1
9+
- pytest>=5.0.1,<6.0.0rc0
1010
- pytest-xdist>=1.21
1111
- pytest-asyncio
1212
- hypothesis>=3.58.0
@@ -18,7 +18,7 @@ dependencies:
1818
- ipython
1919
- jinja2
2020
- lxml
21-
- matplotlib
21+
- matplotlib>=3.3.0
2222
- moto
2323
- nomkl
2424
- numexpr

0 commit comments

Comments
 (0)