Skip to content

Commit 3f9c070

Browse files
committed
Merge remote-tracking branch 'upstream/master' into windows_crlf
2 parents 33c20e4 + 0370740 commit 3f9c070

File tree

442 files changed

+31175
-24043
lines changed

Some content is hidden

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

442 files changed

+31175
-24043
lines changed

.coveragerc

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
[run]
33
branch = False
44
omit = */tests/*
5+
plugins = Cython.Coverage
56

67
[report]
78
# Regexes for lines to exclude from consideration
@@ -22,6 +23,7 @@ exclude_lines =
2223
if __name__ == .__main__.:
2324

2425
ignore_errors = False
26+
show_missing = True
2527

2628
[html]
2729
directory = coverage_html_report

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989

9090

9191

92-
## What is it
92+
## What is it?
9393

9494
**pandas** is a Python package providing fast, flexible, and expressive data
9595
structures designed to make working with "relational" or "labeled" data both

appveyor.yml

+2
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ environment:
2020
matrix:
2121

2222
- CONDA_ROOT: "C:\\Miniconda3_64"
23+
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
2324
PYTHON_VERSION: "3.6"
2425
PYTHON_ARCH: "64"
2526
CONDA_PY: "36"
2627
CONDA_NPY: "113"
2728

2829
- CONDA_ROOT: "C:\\Miniconda3_64"
30+
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
2931
PYTHON_VERSION: "2.7"
3032
PYTHON_ARCH: "64"
3133
CONDA_PY: "27"

asv_bench/benchmarks/groupby.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def time_frame_nth(self, dtype):
142142
def time_series_nth_any(self, dtype):
143143
self.df['values'].groupby(self.df['key']).nth(0, dropna='any')
144144

145-
def time_groupby_nth_all(self, dtype):
145+
def time_series_nth_all(self, dtype):
146146
self.df['values'].groupby(self.df['key']).nth(0, dropna='all')
147147

148148
def time_series_nth(self, dtype):

asv_bench/benchmarks/io/csv.py

+32-20
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,14 @@ def time_frame_date_formatting(self):
5454
self.data.to_csv(self.fname, date_format='%Y%m%d')
5555

5656

57-
class ReadCSVDInferDatetimeFormat(object):
57+
class StringIORewind(object):
58+
59+
def data(self, stringio_object):
60+
stringio_object.seek(0)
61+
return stringio_object
62+
63+
64+
class ReadCSVDInferDatetimeFormat(StringIORewind):
5865

5966
goal_time = 0.2
6067
params = ([True, False], ['custom', 'iso8601', 'ymd'])
@@ -66,10 +73,12 @@ def setup(self, infer_datetime_format, format):
6673
'iso8601': '%Y-%m-%d %H:%M:%S',
6774
'ymd': '%Y%m%d'}
6875
dt_format = formats[format]
69-
self.data = StringIO('\n'.join(rng.strftime(dt_format).tolist()))
76+
self.StringIO_input = StringIO('\n'.join(
77+
rng.strftime(dt_format).tolist()))
7078

7179
def time_read_csv(self, infer_datetime_format, format):
72-
read_csv(self.data, header=None, names=['foo'], parse_dates=['foo'],
80+
read_csv(self.data(self.StringIO_input),
81+
header=None, names=['foo'], parse_dates=['foo'],
7382
infer_datetime_format=infer_datetime_format)
7483

7584

@@ -95,7 +104,7 @@ def time_skipprows(self, skiprows):
95104
read_csv(self.fname, skiprows=skiprows)
96105

97106

98-
class ReadUint64Integers(object):
107+
class ReadUint64Integers(StringIORewind):
99108

100109
goal_time = 0.2
101110

@@ -108,13 +117,13 @@ def setup(self):
108117
self.data2 = StringIO('\n'.join(arr.astype(str).tolist()))
109118

110119
def time_read_uint64(self):
111-
read_csv(self.data1, header=None, names=['foo'])
120+
read_csv(self.data(self.data1), header=None, names=['foo'])
112121

113122
def time_read_uint64_neg_values(self):
114-
read_csv(self.data2, header=None, names=['foo'])
123+
read_csv(self.data(self.data2), header=None, names=['foo'])
115124

116125
def time_read_uint64_na_values(self):
117-
read_csv(self.data1, header=None, names=['foo'],
126+
read_csv(self.data(self.data1), header=None, names=['foo'],
118127
na_values=self.na_values)
119128

120129

@@ -140,19 +149,20 @@ def time_thousands(self, sep, thousands):
140149
read_csv(self.fname, sep=sep, thousands=thousands)
141150

142151

143-
class ReadCSVComment(object):
152+
class ReadCSVComment(StringIORewind):
144153

145154
goal_time = 0.2
146155

147156
def setup(self):
148157
data = ['A,B,C'] + (['1,2,3 # comment'] * 100000)
149-
self.s_data = StringIO('\n'.join(data))
158+
self.StringIO_input = StringIO('\n'.join(data))
150159

151160
def time_comment(self):
152-
read_csv(self.s_data, comment='#', header=None, names=list('abc'))
161+
read_csv(self.data(self.StringIO_input), comment='#',
162+
header=None, names=list('abc'))
153163

154164

155-
class ReadCSVFloatPrecision(object):
165+
class ReadCSVFloatPrecision(StringIORewind):
156166

157167
goal_time = 0.2
158168
params = ([',', ';'], ['.', '_'], [None, 'high', 'round_trip'])
@@ -164,14 +174,14 @@ def setup(self, sep, decimal, float_precision):
164174
rows = sep.join(['0{}'.format(decimal) + '{}'] * 3) + '\n'
165175
data = rows * 5
166176
data = data.format(*floats) * 200 # 1000 x 3 strings csv
167-
self.s_data = StringIO(data)
177+
self.StringIO_input = StringIO(data)
168178

169179
def time_read_csv(self, sep, decimal, float_precision):
170-
read_csv(self.s_data, sep=sep, header=None, names=list('abc'),
171-
float_precision=float_precision)
180+
read_csv(self.data(self.StringIO_input), sep=sep, header=None,
181+
names=list('abc'), float_precision=float_precision)
172182

173183
def time_read_csv_python_engine(self, sep, decimal, float_precision):
174-
read_csv(self.s_data, sep=sep, header=None, engine='python',
184+
read_csv(self.data(self.StringIO_input), sep=sep, header=None, engine='python',
175185
float_precision=None, names=list('abc'))
176186

177187

@@ -193,7 +203,7 @@ def time_convert_direct(self):
193203
read_csv(self.fname, dtype='category')
194204

195205

196-
class ReadCSVParseDates(object):
206+
class ReadCSVParseDates(StringIORewind):
197207

198208
goal_time = 0.2
199209

@@ -206,12 +216,14 @@ def setup(self):
206216
"""
207217
two_cols = ['KORD,19990127'] * 5
208218
data = data.format(*two_cols)
209-
self.s_data = StringIO(data)
219+
self.StringIO_input = StringIO(data)
210220

211221
def time_multiple_date(self):
212-
read_csv(self.s_data, sep=',', header=None,
213-
names=list(string.digits[:9]), parse_dates=[[1, 2], [1, 3]])
222+
read_csv(self.data(self.StringIO_input), sep=',', header=None,
223+
names=list(string.digits[:9]),
224+
parse_dates=[[1, 2], [1, 3]])
214225

215226
def time_baseline(self):
216-
read_csv(self.s_data, sep=',', header=None, parse_dates=[1],
227+
read_csv(self.data(self.StringIO_input), sep=',', header=None,
228+
parse_dates=[1],
217229
names=list(string.digits[:9]))

asv_bench/benchmarks/reshape.py

+18
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import string
12
from itertools import product
23

34
import numpy as np
45
from pandas import DataFrame, MultiIndex, date_range, melt, wide_to_long
6+
import pandas as pd
57

68
from .pandas_vb_common import setup # noqa
79

@@ -132,3 +134,19 @@ def setup(self):
132134

133135
def time_pivot_table(self):
134136
self.df.pivot_table(index='key1', columns=['key2', 'key3'])
137+
138+
139+
class GetDummies(object):
140+
goal_time = 0.2
141+
142+
def setup(self):
143+
categories = list(string.ascii_letters[:12])
144+
s = pd.Series(np.random.choice(categories, size=1000000),
145+
dtype=pd.api.types.CategoricalDtype(categories))
146+
self.s = s
147+
148+
def time_get_dummies_1d(self):
149+
pd.get_dummies(self.s, sparse=False)
150+
151+
def time_get_dummies_1d_sparse(self):
152+
pd.get_dummies(self.s, sparse=True)

asv_bench/benchmarks/series_methods.py

+58
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,64 @@ def time_isin(self, dtypes):
3838
self.s.isin(self.values)
3939

4040

41+
class IsInFloat64(object):
42+
43+
def setup(self):
44+
self.small = Series([1, 2], dtype=np.float64)
45+
self.many_different_values = np.arange(10**6, dtype=np.float64)
46+
self.few_different_values = np.zeros(10**7, dtype=np.float64)
47+
self.only_nans_values = np.full(10**7, np.nan, dtype=np.float64)
48+
49+
def time_isin_many_different(self):
50+
# runtime is dominated by creation of the lookup-table
51+
self.small.isin(self.many_different_values)
52+
53+
def time_isin_few_different(self):
54+
# runtime is dominated by creation of the lookup-table
55+
self.small.isin(self.few_different_values)
56+
57+
def time_isin_nan_values(self):
58+
# runtime is dominated by creation of the lookup-table
59+
self.small.isin(self.few_different_values)
60+
61+
62+
class IsInForObjects(object):
63+
64+
def setup(self):
65+
self.s_nans = Series(np.full(10**4, np.nan)).astype(np.object)
66+
self.vals_nans = np.full(10**4, np.nan).astype(np.object)
67+
self.s_short = Series(np.arange(2)).astype(np.object)
68+
self.s_long = Series(np.arange(10**5)).astype(np.object)
69+
self.vals_short = np.arange(2).astype(np.object)
70+
self.vals_long = np.arange(10**5).astype(np.object)
71+
# because of nans floats are special:
72+
self.s_long_floats = Series(np.arange(10**5,
73+
dtype=np.float)).astype(np.object)
74+
self.vals_long_floats = np.arange(10**5,
75+
dtype=np.float).astype(np.object)
76+
77+
def time_isin_nans(self):
78+
# if nan-objects are different objects,
79+
# this has the potential to trigger O(n^2) running time
80+
self.s_nans.isin(self.vals_nans)
81+
82+
def time_isin_short_series_long_values(self):
83+
# running time dominated by the preprocessing
84+
self.s_short.isin(self.vals_long)
85+
86+
def time_isin_long_series_short_values(self):
87+
# running time dominated by look-up
88+
self.s_long.isin(self.vals_short)
89+
90+
def time_isin_long_series_long_values(self):
91+
# no dominating part
92+
self.s_long.isin(self.vals_long)
93+
94+
def time_isin_long_series_long_values_floats(self):
95+
# no dominating part
96+
self.s_long_floats.isin(self.vals_long_floats)
97+
98+
4199
class NSort(object):
42100

43101
goal_time = 0.2

asv_bench/benchmarks/timeseries.py

+19
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,25 @@ def time_iso8601_tz_spaceformat(self):
343343
to_datetime(self.strings_tz_space)
344344

345345

346+
class ToDatetimeNONISO8601(object):
347+
348+
goal_time = 0.2
349+
350+
def setup(self):
351+
N = 10000
352+
half = int(N / 2)
353+
ts_string_1 = 'March 1, 2018 12:00:00+0400'
354+
ts_string_2 = 'March 1, 2018 12:00:00+0500'
355+
self.same_offset = [ts_string_1] * N
356+
self.diff_offset = [ts_string_1] * half + [ts_string_2] * half
357+
358+
def time_same_offset(self):
359+
to_datetime(self.same_offset)
360+
361+
def time_different_offset(self):
362+
to_datetime(self.diff_offset)
363+
364+
346365
class ToDatetimeFormat(object):
347366

348367
goal_time = 0.2

0 commit comments

Comments
 (0)