Skip to content

Commit a7f3815

Browse files
author
tp
committed
solve merge conflict
2 parents da4b494 + 37086a0 commit a7f3815

File tree

115 files changed

+7113
-6041
lines changed

Some content is hidden

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

115 files changed

+7113
-6041
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,4 @@ doc/build/html/index.html
106106
doc/tmp.sv
107107
doc/source/styled.xlsx
108108
doc/source/templates/
109+
env/

asv_bench/benchmarks/frame_ctor.py

Lines changed: 19 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
import pandas.util.testing as tm
33
from pandas import DataFrame, Series, MultiIndex, Timestamp, date_range
44
try:
5-
from pandas.tseries import offsets
6-
except:
5+
from pandas.tseries.offsets import Nano, Hour
6+
except ImportError:
7+
# For compatability with older versions
78
from pandas.core.datetools import * # noqa
89

910
from .pandas_vb_common import setup # noqa
@@ -24,16 +25,16 @@ def setup(self):
2425
self.data2 = {i: {j: float(j) for j in range(100)}
2526
for i in range(2000)}
2627

27-
def time_frame_ctor_list_of_dict(self):
28+
def time_list_of_dict(self):
2829
DataFrame(self.dict_list)
2930

30-
def time_frame_ctor_nested_dict(self):
31+
def time_nested_dict(self):
3132
DataFrame(self.data)
3233

33-
def time_series_ctor_from_dict(self):
34+
def time_dict(self):
3435
Series(self.some_dict)
3536

36-
def time_frame_ctor_nested_dict_int64(self):
37+
def time_nested_dict_int64(self):
3738
# nested dict, integer indexes, regression described in #621
3839
DataFrame(self.data2)
3940

@@ -46,78 +47,24 @@ def setup(self):
4647
mi = MultiIndex.from_product([range(100), range(100)])
4748
self.s = Series(np.random.randn(10000), index=mi)
4849

49-
def time_frame_from_mi_series(self):
50+
def time_mi_series(self):
5051
DataFrame(self.s)
5152

52-
# ----------------------------------------------------------------------
53-
# From dict with DatetimeIndex with all offsets
5453

55-
# dynamically generate benchmarks for every offset
56-
#
57-
# get_period_count & get_index_for_offset are there because blindly taking each
58-
# offset times 1000 can easily go out of Timestamp bounds and raise errors.
54+
class FromDictwithTimestamp(object):
5955

56+
goal_time = 0.2
57+
params = [Nano(1), Hour(1)]
58+
param_names = ['offset']
6059

61-
def get_period_count(start_date, off):
62-
ten_offsets_in_days = ((start_date + (off * 10)) - start_date).days
63-
if (ten_offsets_in_days == 0):
64-
return 1000
65-
else:
66-
periods = 9 * (Timestamp.max - start_date).days // ten_offsets_in_days
67-
return min(periods, 1000)
68-
69-
70-
def get_index_for_offset(off):
71-
start_date = Timestamp('1/1/1900')
72-
return date_range(start_date,
73-
periods=get_period_count(start_date, off),
74-
freq=off)
75-
76-
77-
all_offsets = offsets.__all__
78-
# extra cases
79-
for off in ['FY5253', 'FY5253Quarter']:
80-
all_offsets.pop(all_offsets.index(off))
81-
all_offsets.extend([off + '_1', off + '_2'])
82-
83-
84-
class FromDictwithTimestampOffsets(object):
85-
86-
params = [all_offsets, [1, 2]]
87-
param_names = ['offset', 'n_steps']
88-
89-
offset_kwargs = {'WeekOfMonth': {'weekday': 1, 'week': 1},
90-
'LastWeekOfMonth': {'weekday': 1, 'week': 1},
91-
'FY5253': {'startingMonth': 1, 'weekday': 1},
92-
'FY5253Quarter': {'qtr_with_extra_week': 1,
93-
'startingMonth': 1,
94-
'weekday': 1}}
95-
96-
offset_extra_cases = {'FY5253': {'variation': ['nearest', 'last']},
97-
'FY5253Quarter': {'variation': ['nearest', 'last']}}
98-
99-
def setup(self, offset, n_steps):
60+
def setup(self, offset):
61+
N = 10**3
10062
np.random.seed(1234)
101-
extra = False
102-
if offset.endswith("_", None, -1):
103-
extra = int(offset[-1])
104-
offset = offset[:-2]
105-
106-
kwargs = {}
107-
if offset in self.offset_kwargs:
108-
kwargs = self.offset_kwargs[offset]
109-
110-
if extra:
111-
extras = self.offset_extra_cases[offset]
112-
for extra_arg in extras:
113-
kwargs[extra_arg] = extras[extra_arg][extra - 1]
114-
115-
offset = getattr(offsets, offset)
116-
self.idx = get_index_for_offset(offset(n_steps, **kwargs))
117-
self.df = DataFrame(np.random.randn(len(self.idx), 10), index=self.idx)
118-
self.d = self.df.to_dict()
119-
120-
def time_frame_ctor(self, offset, n_steps):
63+
idx = date_range(Timestamp('1/1/1900'), freq=offset, periods=N)
64+
df = DataFrame(np.random.randn(N, 10), index=idx)
65+
self.d = df.to_dict()
66+
67+
def time_dict_with_timestamp_offsets(self, offset):
12168
DataFrame(self.d)
12269

12370

asv_bench/benchmarks/timedelta.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
from .pandas_vb_common import *
2-
from pandas import to_timedelta, Timestamp
1+
import numpy as np
2+
import pandas as pd
3+
4+
from pandas import to_timedelta, Timestamp, Timedelta
35

46

57
class ToTimedelta(object):
@@ -67,8 +69,8 @@ class DatetimeAccessor(object):
6769
def setup(self):
6870
self.N = 100000
6971
self.series = pd.Series(
70-
pd.timedelta_range('1 days', periods=self.N, freq='h')
71-
)
72+
pd.timedelta_range('1 days', periods=self.N, freq='h'))
73+
7274
def time_dt_accessor(self):
7375
self.series.dt
7476

asv_bench/benchmarks/timeseries.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def time_dti_tz_factorize(self):
8585
self.dti_tz.factorize()
8686

8787
def time_dti_time(self):
88-
self.rng.time
88+
self.dst_rng.time
8989

9090
def time_timestamp_tzinfo_cons(self):
9191
self.rng5[0]

asv_bench/benchmarks/timestamp.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,33 @@
1-
from pandas import to_timedelta, Timestamp
1+
from pandas import Timestamp
22
import pytz
33
import datetime
44

55

6+
class TimestampConstruction(object):
7+
# TODO: classmethod constructors: fromordinal, fromtimestamp...
8+
9+
def time_parse_iso8601_no_tz(self):
10+
Timestamp('2017-08-25 08:16:14')
11+
12+
def time_parse_iso8601_tz(self):
13+
Timestamp('2017-08-25 08:16:14-0500')
14+
15+
def time_parse_dateutil(self):
16+
Timestamp('2017/08/25 08:16:14 AM')
17+
18+
def time_parse_today(self):
19+
Timestamp('today')
20+
21+
def time_parse_now(self):
22+
Timestamp('now')
23+
24+
625
class TimestampProperties(object):
726
goal_time = 0.2
827

9-
params = [(None, None),
10-
(pytz.timezone('Europe/Amsterdam'), None),
11-
(None, 'B'),
12-
(pytz.timezone('Europe/Amsterdam'), 'B')]
28+
_tzs = [None, pytz.timezone('Europe/Amsterdam')]
29+
_freqs = [None, 'B']
30+
params = [_tzs, _freqs]
1331
param_names = ['tz', 'freq']
1432

1533
def setup(self, tz, freq):

ci/check_imports.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
'ipython',
1010
'jinja2'
1111
'lxml',
12-
'matplotlib',
1312
'numexpr',
1413
'openpyxl',
1514
'py',

ci/environment-dev.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ dependencies:
1010
- python-dateutil>=2.5.0
1111
- python=3
1212
- pytz
13-
- setuptools
13+
- setuptools>=3.3
1414
- sphinx

ci/lint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ if [ "$LINT" ]; then
2323
fi
2424
echo "Linting setup.py DONE"
2525

26+
echo "Linting asv_bench/benchmarks/"
27+
flake8 asv_bench/benchmarks/ --exclude=asv_bench/benchmarks/[ghijoprs]*.py --ignore=F811
28+
if [ $? -ne "0" ]; then
29+
RET=1
30+
fi
31+
echo "Linting asv_bench/benchmarks/*.py DONE"
32+
2633
echo "Linting *.pyx"
2734
flake8 pandas --filename=*.pyx --select=E501,E302,E203,E111,E114,E221,E303,E128,E231,E126,E265,E305,E301,E127,E261,E271,E129,W291,E222,E241,E123,F403
2835
if [ $? -ne "0" ]; then

ci/requirements_dev.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ moto
66
pytest>=3.1
77
python-dateutil>=2.5.0
88
pytz
9-
setuptools
10-
sphinx
9+
setuptools>=3.3
10+
sphinx

conda.recipe/meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ requirements:
1515
- python
1616
- cython
1717
- numpy x.x
18-
- setuptools
18+
- setuptools >=3.3
1919

2020
run:
2121
- python

0 commit comments

Comments
 (0)