Merge master into GH13936
This commit is contained in:
commit
5eeb7d98b2
|
@ -16,7 +16,7 @@ env:
|
|||
global:
|
||||
|
||||
# pandas-docs-travis GH
|
||||
- secure: "PCzUFR8CHmw9lH84p4ygnojdF7Z8U5h7YfY0RyT+5K/aiQ1ZTU3ZkDTPI0/rR5FVMxsEEKEQKMcc5fvqW0PeD7Q2wRmluloKgT9w4EVEJ1ppKf7lITPcvZR2QgVOvjv4AfDtibLHFNiaSjzoqyJVjM4igjOu8WTlF3JfZcmOQjQ="
|
||||
- secure: "YvvTc+FrSYHgdxqoxn9s8VOaCWjvZzlkaf6k55kkmQqCYR9dPiLMsot1F96/N7o3YlD1s0znPQCak93Du8HHi/8809zAXloTaMSZrWz4R4qn96xlZFRE88O/w/Z1t3VVYpKX3MHlCggBc8MtXrqmvWKJMAqXyysZ4TTzoiJDPvE="
|
||||
|
||||
git:
|
||||
# for cloning
|
||||
|
|
|
@ -3,7 +3,7 @@ import pandas as pd
|
|||
from pandas.util import testing as tm
|
||||
|
||||
|
||||
class algorithm(object):
|
||||
class Algorithms(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
|
@ -24,21 +24,28 @@ class algorithm(object):
|
|||
self.arrneg = np.arange(-1000000, 0)
|
||||
self.arrmixed = np.array([1, -1]).repeat(500000)
|
||||
|
||||
def time_int_factorize(self):
|
||||
# match
|
||||
self.uniques = tm.makeStringIndex(1000).values
|
||||
self.all = self.uniques.repeat(10)
|
||||
|
||||
def time_factorize_int(self):
|
||||
self.int.factorize()
|
||||
|
||||
def time_float_factorize(self):
|
||||
def time_factorize_float(self):
|
||||
self.int.factorize()
|
||||
|
||||
def time_int_unique_duplicated(self):
|
||||
def time_duplicated_int_unique(self):
|
||||
self.int_unique.duplicated()
|
||||
|
||||
def time_int_duplicated(self):
|
||||
def time_duplicated_int(self):
|
||||
self.int.duplicated()
|
||||
|
||||
def time_float_duplicated(self):
|
||||
def time_duplicated_float(self):
|
||||
self.float.duplicated()
|
||||
|
||||
def time_match_strings(self):
|
||||
pd.match(self.all, self.uniques)
|
||||
|
||||
def time_add_overflow_pos_scalar(self):
|
||||
self.checked_add(self.arr, 1)
|
||||
|
||||
|
@ -58,7 +65,7 @@ class algorithm(object):
|
|||
self.checked_add(self.arr, self.arrmixed)
|
||||
|
||||
|
||||
class hashing(object):
|
||||
class Hashing(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
|
|
|
@ -1,23 +1,32 @@
|
|||
from .pandas_vb_common import *
|
||||
from pandas.util.decorators import cache_readonly
|
||||
|
||||
|
||||
class getattr_dataframe_index(object):
|
||||
class DataFrameAttributes(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.df = DataFrame(np.random.randn(10, 6))
|
||||
self.cur_index = self.df.index
|
||||
|
||||
def time_getattr_dataframe_index(self):
|
||||
def time_get_index(self):
|
||||
self.foo = self.df.index
|
||||
|
||||
def time_set_index(self):
|
||||
self.df.index = self.cur_index
|
||||
|
||||
class setattr_dataframe_index(object):
|
||||
|
||||
class CacheReadonly(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.df = DataFrame(np.random.randn(10, 6))
|
||||
self.cur_index = self.df.index
|
||||
|
||||
def time_setattr_dataframe_index(self):
|
||||
self.df.index = self.cur_index
|
||||
class Foo:
|
||||
|
||||
@cache_readonly
|
||||
def prop(self):
|
||||
return 5
|
||||
self.obj = Foo()
|
||||
|
||||
def time_cache_readonly(self):
|
||||
self.obj.prop
|
||||
|
|
|
@ -2,193 +2,79 @@ from .pandas_vb_common import *
|
|||
import pandas.computation.expressions as expr
|
||||
|
||||
|
||||
class frame_add(object):
|
||||
class Ops(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
params = [[True, False], ['default', 1]]
|
||||
param_names = ['use_numexpr', 'threads']
|
||||
|
||||
def setup(self, use_numexpr, threads):
|
||||
self.df = DataFrame(np.random.randn(20000, 100))
|
||||
self.df2 = DataFrame(np.random.randn(20000, 100))
|
||||
|
||||
def time_frame_add(self):
|
||||
if threads != 'default':
|
||||
expr.set_numexpr_threads(threads)
|
||||
if not use_numexpr:
|
||||
expr.set_use_numexpr(False)
|
||||
|
||||
|
||||
def time_frame_add(self, use_numexpr, threads):
|
||||
(self.df + self.df2)
|
||||
|
||||
def time_frame_mult(self, use_numexpr, threads):
|
||||
(self.df * self.df2)
|
||||
|
||||
class frame_add_no_ne(object):
|
||||
goal_time = 0.2
|
||||
def time_frame_multi_and(self, use_numexpr, threads):
|
||||
self.df[((self.df > 0) & (self.df2 > 0))]
|
||||
|
||||
def setup(self):
|
||||
self.df = DataFrame(np.random.randn(20000, 100))
|
||||
self.df2 = DataFrame(np.random.randn(20000, 100))
|
||||
expr.set_use_numexpr(False)
|
||||
def time_frame_comparison(self, use_numexpr, threads):
|
||||
(self.df > self.df2)
|
||||
|
||||
def time_frame_add_no_ne(self):
|
||||
(self.df + self.df2)
|
||||
|
||||
def teardown(self):
|
||||
def teardown(self, use_numexpr, threads):
|
||||
expr.set_use_numexpr(True)
|
||||
|
||||
|
||||
class frame_add_st(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.df = DataFrame(np.random.randn(20000, 100))
|
||||
self.df2 = DataFrame(np.random.randn(20000, 100))
|
||||
expr.set_numexpr_threads(1)
|
||||
|
||||
def time_frame_add_st(self):
|
||||
(self.df + self.df2)
|
||||
|
||||
def teardown(self):
|
||||
expr.set_numexpr_threads()
|
||||
|
||||
|
||||
class frame_float_div(object):
|
||||
class Ops2(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.df = DataFrame(np.random.randn(1000, 1000))
|
||||
self.df2 = DataFrame(np.random.randn(1000, 1000))
|
||||
|
||||
self.df_int = DataFrame(
|
||||
np.random.random_integers(np.iinfo(np.int16).min,
|
||||
np.iinfo(np.int16).max,
|
||||
size=(1000, 1000)))
|
||||
self.df2_int = DataFrame(
|
||||
np.random.random_integers(np.iinfo(np.int16).min,
|
||||
np.iinfo(np.int16).max,
|
||||
size=(1000, 1000)))
|
||||
|
||||
## Division
|
||||
|
||||
def time_frame_float_div(self):
|
||||
(self.df // self.df2)
|
||||
|
||||
|
||||
class frame_float_div_by_zero(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.df = DataFrame(np.random.randn(1000, 1000))
|
||||
|
||||
def time_frame_float_div_by_zero(self):
|
||||
(self.df / 0)
|
||||
|
||||
|
||||
class frame_float_floor_by_zero(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.df = DataFrame(np.random.randn(1000, 1000))
|
||||
|
||||
def time_frame_float_floor_by_zero(self):
|
||||
(self.df // 0)
|
||||
|
||||
def time_frame_int_div_by_zero(self):
|
||||
(self.df_int / 0)
|
||||
|
||||
class frame_float_mod(object):
|
||||
goal_time = 0.2
|
||||
## Modulo
|
||||
|
||||
def setup(self):
|
||||
self.df = DataFrame(np.random.randn(1000, 1000))
|
||||
self.df2 = DataFrame(np.random.randn(1000, 1000))
|
||||
def time_frame_int_mod(self):
|
||||
(self.df / self.df2)
|
||||
|
||||
def time_frame_float_mod(self):
|
||||
(self.df / self.df2)
|
||||
|
||||
|
||||
class frame_int_div_by_zero(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.df = DataFrame(np.random.random_integers(np.iinfo(np.int16).min, np.iinfo(np.int16).max, size=(1000, 1000)))
|
||||
|
||||
def time_frame_int_div_by_zero(self):
|
||||
(self.df / 0)
|
||||
|
||||
|
||||
class frame_int_mod(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.df = DataFrame(np.random.random_integers(np.iinfo(np.int16).min, np.iinfo(np.int16).max, size=(1000, 1000)))
|
||||
self.df2 = DataFrame(np.random.random_integers(np.iinfo(np.int16).min, np.iinfo(np.int16).max, size=(1000, 1000)))
|
||||
|
||||
def time_frame_int_mod(self):
|
||||
(self.df / self.df2)
|
||||
|
||||
|
||||
class frame_mult(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.df = DataFrame(np.random.randn(20000, 100))
|
||||
self.df2 = DataFrame(np.random.randn(20000, 100))
|
||||
|
||||
def time_frame_mult(self):
|
||||
(self.df * self.df2)
|
||||
|
||||
|
||||
class frame_mult_no_ne(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.df = DataFrame(np.random.randn(20000, 100))
|
||||
self.df2 = DataFrame(np.random.randn(20000, 100))
|
||||
expr.set_use_numexpr(False)
|
||||
|
||||
def time_frame_mult_no_ne(self):
|
||||
(self.df * self.df2)
|
||||
|
||||
def teardown(self):
|
||||
expr.set_use_numexpr(True)
|
||||
|
||||
|
||||
class frame_mult_st(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.df = DataFrame(np.random.randn(20000, 100))
|
||||
self.df2 = DataFrame(np.random.randn(20000, 100))
|
||||
expr.set_numexpr_threads(1)
|
||||
|
||||
def time_frame_mult_st(self):
|
||||
(self.df * self.df2)
|
||||
|
||||
def teardown(self):
|
||||
expr.set_numexpr_threads()
|
||||
|
||||
|
||||
class frame_multi_and(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.df = DataFrame(np.random.randn(20000, 100))
|
||||
self.df2 = DataFrame(np.random.randn(20000, 100))
|
||||
|
||||
def time_frame_multi_and(self):
|
||||
self.df[((self.df > 0) & (self.df2 > 0))]
|
||||
|
||||
|
||||
class frame_multi_and_no_ne(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.df = DataFrame(np.random.randn(20000, 100))
|
||||
self.df2 = DataFrame(np.random.randn(20000, 100))
|
||||
expr.set_use_numexpr(False)
|
||||
|
||||
def time_frame_multi_and_no_ne(self):
|
||||
self.df[((self.df > 0) & (self.df2 > 0))]
|
||||
|
||||
def teardown(self):
|
||||
expr.set_use_numexpr(True)
|
||||
|
||||
|
||||
class frame_multi_and_st(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.df = DataFrame(np.random.randn(20000, 100))
|
||||
self.df2 = DataFrame(np.random.randn(20000, 100))
|
||||
expr.set_numexpr_threads(1)
|
||||
|
||||
def time_frame_multi_and_st(self):
|
||||
self.df[((self.df > 0) & (self.df2 > 0))]
|
||||
|
||||
def teardown(self):
|
||||
expr.set_numexpr_threads()
|
||||
|
||||
|
||||
class series_timestamp_compare(object):
|
||||
class Timeseries(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
|
@ -197,65 +83,28 @@ class series_timestamp_compare(object):
|
|||
self.s = Series(date_range('20010101', periods=self.N, freq='T'))
|
||||
self.ts = self.s[self.halfway]
|
||||
|
||||
self.s2 = Series(date_range('20010101', periods=self.N, freq='s'))
|
||||
|
||||
def time_series_timestamp_compare(self):
|
||||
(self.s <= self.ts)
|
||||
|
||||
|
||||
class timestamp_ops_diff1(object):
|
||||
goal_time = 0.2
|
||||
N = 1000000
|
||||
|
||||
def setup(self):
|
||||
self.s = self.create()
|
||||
|
||||
def create(self):
|
||||
return Series(date_range('20010101', periods=self.N, freq='s'))
|
||||
|
||||
def time_timestamp_ops_diff1(self):
|
||||
self.s.diff()
|
||||
|
||||
class timestamp_tz_ops_diff1(timestamp_ops_diff1):
|
||||
N = 10000
|
||||
|
||||
def create(self):
|
||||
return Series(date_range('20010101', periods=self.N, freq='s', tz='US/Eastern'))
|
||||
|
||||
class timestamp_ops_diff2(object):
|
||||
goal_time = 0.2
|
||||
N = 1000000
|
||||
|
||||
def setup(self):
|
||||
self.s = self.create()
|
||||
|
||||
def create(self):
|
||||
return Series(date_range('20010101', periods=self.N, freq='s'))
|
||||
|
||||
def time_timestamp_ops_diff2(self):
|
||||
(self.s - self.s.shift())
|
||||
|
||||
class timestamp_tz_ops_diff2(timestamp_ops_diff2):
|
||||
N = 10000
|
||||
|
||||
def create(self):
|
||||
return Series(date_range('20010101', periods=self.N, freq='s', tz='US/Eastern'))
|
||||
|
||||
class timestamp_series_compare(object):
|
||||
goal_time = 0.2
|
||||
N = 1000000
|
||||
|
||||
def setup(self):
|
||||
self.halfway = ((self.N // 2) - 1)
|
||||
self.s = self.create()
|
||||
self.ts = self.s[self.halfway]
|
||||
|
||||
def create(self):
|
||||
return Series(date_range('20010101', periods=self.N, freq='T'))
|
||||
|
||||
def time_timestamp_series_compare(self):
|
||||
(self.ts >= self.s)
|
||||
|
||||
class timestamp_tz_series_compare(timestamp_series_compare):
|
||||
N = 10000
|
||||
def time_timestamp_ops_diff1(self):
|
||||
self.s2.diff()
|
||||
|
||||
def create(self):
|
||||
return Series(date_range('20010101', periods=self.N, freq='T', tz='US/Eastern'))
|
||||
def time_timestamp_ops_diff2(self):
|
||||
(self.s - self.s.shift())
|
||||
|
||||
|
||||
|
||||
class TimeseriesTZ(Timeseries):
|
||||
|
||||
def setup(self):
|
||||
self.N = 1000000
|
||||
self.halfway = ((self.N // 2) - 1)
|
||||
self.s = Series(date_range('20010101', periods=self.N, freq='T', tz='US/Eastern'))
|
||||
self.ts = self.s[self.halfway]
|
||||
|
||||
self.s2 = Series(date_range('20010101', periods=self.N, freq='s', tz='US/Eastern'))
|
|
@ -3,32 +3,49 @@ try:
|
|||
from pandas.types.concat import union_categoricals
|
||||
except ImportError:
|
||||
pass
|
||||
import string
|
||||
|
||||
|
||||
class concat_categorical(object):
|
||||
class Categoricals(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.s = pd.Series((list('aabbcd') * 1000000)).astype('category')
|
||||
N = 100000
|
||||
self.s = pd.Series((list('aabbcd') * N)).astype('category')
|
||||
|
||||
def time_concat_categorical(self):
|
||||
self.a = pd.Categorical((list('aabbcd') * N))
|
||||
self.b = pd.Categorical((list('bbcdjk') * N))
|
||||
|
||||
self.categories = list('abcde')
|
||||
self.cat_idx = Index(self.categories)
|
||||
self.values = np.tile(self.categories, N)
|
||||
self.codes = np.tile(range(len(self.categories)), N)
|
||||
|
||||
self.datetimes = pd.Series(pd.date_range(
|
||||
'1995-01-01 00:00:00', periods=10000, freq='s'))
|
||||
|
||||
def time_concat(self):
|
||||
concat([self.s, self.s])
|
||||
|
||||
|
||||
class union_categorical(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.a = pd.Categorical((list('aabbcd') * 1000000))
|
||||
self.b = pd.Categorical((list('bbcdjk') * 1000000))
|
||||
|
||||
def time_union_categorical(self):
|
||||
def time_union(self):
|
||||
union_categoricals([self.a, self.b])
|
||||
|
||||
def time_constructor_regular(self):
|
||||
Categorical(self.values, self.categories)
|
||||
|
||||
class categorical_value_counts(object):
|
||||
goal_time = 1
|
||||
def time_constructor_fastpath(self):
|
||||
Categorical(self.codes, self.cat_idx, fastpath=True)
|
||||
|
||||
def time_constructor_datetimes(self):
|
||||
Categorical(self.datetimes)
|
||||
|
||||
def time_constructor_datetimes_with_nat(self):
|
||||
t = self.datetimes
|
||||
t.iloc[-1] = pd.NaT
|
||||
Categorical(t)
|
||||
|
||||
|
||||
class Categoricals2(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
n = 500000
|
||||
|
@ -36,56 +53,13 @@ class categorical_value_counts(object):
|
|||
arr = ['s%04d' % i for i in np.random.randint(0, n // 10, size=n)]
|
||||
self.ts = Series(arr).astype('category')
|
||||
|
||||
self.sel = self.ts.loc[[0]]
|
||||
|
||||
def time_value_counts(self):
|
||||
self.ts.value_counts(dropna=False)
|
||||
|
||||
def time_value_counts_dropna(self):
|
||||
self.ts.value_counts(dropna=True)
|
||||
|
||||
|
||||
class categorical_constructor(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
n = 5
|
||||
N = 1e6
|
||||
self.categories = list(string.ascii_letters[:n])
|
||||
self.cat_idx = Index(self.categories)
|
||||
self.values = np.tile(self.categories, N)
|
||||
self.codes = np.tile(range(n), N)
|
||||
|
||||
def time_regular_constructor(self):
|
||||
Categorical(self.values, self.categories)
|
||||
|
||||
def time_fastpath(self):
|
||||
Categorical(self.codes, self.cat_idx, fastpath=True)
|
||||
|
||||
|
||||
class categorical_constructor_with_datetimes(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.datetimes = pd.Series(pd.date_range(
|
||||
'1995-01-01 00:00:00', periods=10000, freq='s'))
|
||||
|
||||
def time_datetimes(self):
|
||||
Categorical(self.datetimes)
|
||||
|
||||
def time_datetimes_with_nat(self):
|
||||
t = self.datetimes
|
||||
t.iloc[-1] = pd.NaT
|
||||
Categorical(t)
|
||||
|
||||
|
||||
class categorical_rendering(object):
|
||||
goal_time = 3e-3
|
||||
|
||||
def setup(self):
|
||||
n = 1000
|
||||
items = [str(i) for i in range(n)]
|
||||
s = pd.Series(items, dtype='category')
|
||||
df = pd.DataFrame({'C': s, 'data': np.random.randn(n)})
|
||||
self.data = df[df.C == '20']
|
||||
|
||||
def time_rendering(self):
|
||||
str(self.data.C)
|
||||
str(self.sel)
|
||||
|
|
|
@ -1,52 +1,30 @@
|
|||
from .pandas_vb_common import *
|
||||
|
||||
|
||||
class frame_constructor_ndarray(object):
|
||||
class Constructors(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.arr = np.random.randn(100, 100)
|
||||
self.arr_str = np.array(['foo', 'bar', 'baz'], dtype=object)
|
||||
|
||||
def time_frame_constructor_ndarray(self):
|
||||
DataFrame(self.arr)
|
||||
|
||||
|
||||
class ctor_index_array_string(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.data = np.array(['foo', 'bar', 'baz'], dtype=object)
|
||||
|
||||
def time_ctor_index_array_string(self):
|
||||
Index(self.data)
|
||||
|
||||
|
||||
class series_constructor_ndarray(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.data = np.random.randn(100)
|
||||
self.index = Index(np.arange(100))
|
||||
|
||||
def time_series_constructor_ndarray(self):
|
||||
Series(self.data, index=self.index)
|
||||
self.s = Series(([Timestamp('20110101'), Timestamp('20120101'),
|
||||
Timestamp('20130101')] * 1000))
|
||||
|
||||
def time_frame_from_ndarray(self):
|
||||
DataFrame(self.arr)
|
||||
|
||||
class dtindex_from_series_ctor(object):
|
||||
goal_time = 0.2
|
||||
def time_series_from_ndarray(self):
|
||||
pd.Series(self.data, index=self.index)
|
||||
|
||||
def setup(self):
|
||||
self.s = Series(([Timestamp('20110101'), Timestamp('20120101'), Timestamp('20130101')] * 1000))
|
||||
def time_index_from_array_string(self):
|
||||
Index(self.arr_str)
|
||||
|
||||
def time_dtindex_from_series_ctor(self):
|
||||
def time_dtindex_from_series(self):
|
||||
DatetimeIndex(self.s)
|
||||
|
||||
|
||||
class index_from_series_ctor(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.s = Series(([Timestamp('20110101'), Timestamp('20120101'), Timestamp('20130101')] * 1000))
|
||||
|
||||
def time_index_from_series_ctor(self):
|
||||
def time_dtindex_from_series2(self):
|
||||
Index(self.s)
|
||||
|
|
|
@ -3,7 +3,7 @@ import pandas as pd
|
|||
import pandas.computation.expressions as expr
|
||||
|
||||
|
||||
class eval_frame(object):
|
||||
class Eval(object):
|
||||
goal_time = 0.2
|
||||
|
||||
params = [['numexpr', 'python'], [1, 'all']]
|
||||
|
@ -34,8 +34,11 @@ class eval_frame(object):
|
|||
df, df2, df3, df4 = self.df, self.df2, self.df3, self.df4
|
||||
pd.eval('df * df2 * df3 * df4', engine=engine)
|
||||
|
||||
def teardown(self, engine, threads):
|
||||
expr.set_numexpr_threads()
|
||||
|
||||
class query_datetime_index(object):
|
||||
|
||||
class Query(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
|
@ -45,41 +48,19 @@ class query_datetime_index(object):
|
|||
self.s = Series(self.index)
|
||||
self.ts = self.s.iloc[self.halfway]
|
||||
self.df = DataFrame({'a': np.random.randn(self.N), }, index=self.index)
|
||||
self.df2 = DataFrame({'dates': self.s.values,})
|
||||
|
||||
self.df3 = DataFrame({'a': np.random.randn(self.N),})
|
||||
self.min_val = self.df3['a'].min()
|
||||
self.max_val = self.df3['a'].max()
|
||||
|
||||
def time_query_datetime_index(self):
|
||||
ts = self.ts
|
||||
self.df.query('index < @ts')
|
||||
|
||||
|
||||
class query_datetime_series(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.N = 1000000
|
||||
self.halfway = ((self.N // 2) - 1)
|
||||
self.index = date_range('20010101', periods=self.N, freq='T')
|
||||
self.s = Series(self.index)
|
||||
self.ts = self.s.iloc[self.halfway]
|
||||
self.df = DataFrame({'dates': self.s.values, })
|
||||
|
||||
def time_query_datetime_series(self):
|
||||
ts = self.ts
|
||||
self.df.query('dates < @ts')
|
||||
|
||||
|
||||
class query_with_boolean_selection(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.N = 1000000
|
||||
self.halfway = ((self.N // 2) - 1)
|
||||
self.index = date_range('20010101', periods=self.N, freq='T')
|
||||
self.s = Series(self.index)
|
||||
self.ts = self.s.iloc[self.halfway]
|
||||
self.N = 1000000
|
||||
self.df = DataFrame({'a': np.random.randn(self.N), })
|
||||
self.min_val = self.df['a'].min()
|
||||
self.max_val = self.df['a'].max()
|
||||
self.df2.query('dates < @ts')
|
||||
|
||||
def time_query_with_boolean_selection(self):
|
||||
min_val, max_val = self.min_val, self.max_val
|
||||
|
|
|
@ -5,1617 +5,10 @@ except:
|
|||
from pandas.core.datetools import *
|
||||
|
||||
|
||||
class frame_ctor_dtindex_BDayx1(object):
|
||||
goal_time = 0.2
|
||||
#----------------------------------------------------------------------
|
||||
# Creation from nested dict
|
||||
|
||||
def setup(self):
|
||||
self.idx = self.get_index_for_offset(BDay(1, **{}))
|
||||
self.df = DataFrame(np.random.randn(len(self.idx), 10), index=self.idx)
|
||||
self.d = dict([(col, self.df[col]) for col in self.df.columns])
|
||||
|
||||
def time_frame_ctor_dtindex_BDayx1(self):
|
||||
DataFrame(self.d)
|
||||
|
||||
def get_period_count(self, start_date, off):
|
||||
self.ten_offsets_in_days = ((start_date + (off * 10)) - start_date).days
|
||||
if (self.ten_offsets_in_days == 0):
|
||||
return 1000
|
||||
else:
|
||||
return min((9 * ((Timestamp.max - start_date).days // self.ten_offsets_in_days)), 1000)
|
||||
|
||||
def get_index_for_offset(self, off):
|
||||
self.start_date = Timestamp('1/1/1900')
|
||||
return date_range(self.start_date, periods=min(1000, self.get_period_count(self.start_date, off)), freq=off)
|
||||
|
||||
|
||||
class frame_ctor_dtindex_BDayx2(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.idx = self.get_index_for_offset(BDay(2, **{}))
|
||||
self.df = DataFrame(np.random.randn(len(self.idx), 10), index=self.idx)
|
||||
self.d = dict([(col, self.df[col]) for col in self.df.columns])
|
||||
|
||||
def time_frame_ctor_dtindex_BDayx2(self):
|
||||
DataFrame(self.d)
|
||||
|
||||
def get_period_count(self, start_date, off):
|
||||
self.ten_offsets_in_days = ((start_date + (off * 10)) - start_date).days
|
||||
if (self.ten_offsets_in_days == 0):
|
||||
return 1000
|
||||
else:
|
||||
return min((9 * ((Timestamp.max - start_date).days // self.ten_offsets_in_days)), 1000)
|
||||
|
||||
def get_index_for_offset(self, off):
|
||||
self.start_date = Timestamp('1/1/1900')
|
||||
return date_range(self.start_date, periods=min(1000, self.get_period_count(self.start_date, off)), freq=off)
|
||||
|
||||
|
||||
class frame_ctor_dtindex_BMonthBeginx1(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.idx = self.get_index_for_offset(BMonthBegin(1, **{}))
|
||||
self.df = DataFrame(np.random.randn(len(self.idx), 10), index=self.idx)
|
||||
self.d = dict([(col, self.df[col]) for col in self.df.columns])
|
||||
|
||||
def time_frame_ctor_dtindex_BMonthBeginx1(self):
|
||||
DataFrame(self.d)
|
||||
|
||||
def get_period_count(self, start_date, off):
|
||||
self.ten_offsets_in_days = ((start_date + (off * 10)) - start_date).days
|
||||
if (self.ten_offsets_in_days == 0):
|
||||
return 1000
|
||||
else:
|
||||
return min((9 * ((Timestamp.max - start_date).days // self.ten_offsets_in_days)), 1000)
|
||||
|
||||
def get_index_for_offset(self, off):
|
||||
self.start_date = Timestamp('1/1/1900')
|
||||
return date_range(self.start_date, periods=min(1000, self.get_period_count(self.start_date, off)), freq=off)
|
||||
|
||||
|
||||
class frame_ctor_dtindex_BMonthBeginx2(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.idx = self.get_index_for_offset(BMonthBegin(2, **{}))
|
||||
self.df = DataFrame(np.random.randn(len(self.idx), 10), index=self.idx)
|
||||
self.d = dict([(col, self.df[col]) for col in self.df.columns])
|
||||
|
||||
def time_frame_ctor_dtindex_BMonthBeginx2(self):
|
||||
DataFrame(self.d)
|
||||
|
||||
def get_period_count(self, start_date, off):
|
||||
self.ten_offsets_in_days = ((start_date + (off * 10)) - start_date).days
|
||||
if (self.ten_offsets_in_days == 0):
|
||||
return 1000
|
||||
else:
|
||||
return min((9 * ((Timestamp.max - start_date).days // self.ten_offsets_in_days)), 1000)
|
||||
|
||||
def get_index_for_offset(self, off):
|
||||
self.start_date = Timestamp('1/1/1900')
|
||||
return date_range(self.start_date, periods=min(1000, self.get_period_count(self.start_date, off)), freq=off)
|
||||
|
||||
|
||||
class frame_ctor_dtindex_BMonthEndx1(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.idx = self.get_index_for_offset(BMonthEnd(1, **{}))
|
||||
self.df = DataFrame(np.random.randn(len(self.idx), 10), index=self.idx)
|
||||
self.d = dict([(col, self.df[col]) for col in self.df.columns])
|
||||
|
||||
def time_frame_ctor_dtindex_BMonthEndx1(self):
|
||||
DataFrame(self.d)
|
||||
|
||||
def get_period_count(self, start_date, off):
|
||||
self.ten_offsets_in_days = ((start_date + (off * 10)) - start_date).days
|
||||
if (self.ten_offsets_in_days == 0):
|
||||
return 1000
|
||||
else:
|
||||
return min((9 * ((Timestamp.max - start_date).days // self.ten_offsets_in_days)), 1000)
|
||||
|
||||
def get_index_for_offset(self, off):
|
||||
self.start_date = Timestamp('1/1/1900')
|
||||
return date_range(self.start_date, periods=min(1000, self.get_period_count(self.start_date, off)), freq=off)
|
||||
|
||||
|
||||
class frame_ctor_dtindex_BMonthEndx2(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.idx = self.get_index_for_offset(BMonthEnd(2, **{}))
|
||||
self.df = DataFrame(np.random.randn(len(self.idx), 10), index=self.idx)
|
||||
self.d = dict([(col, self.df[col]) for col in self.df.columns])
|
||||
|
||||
def time_frame_ctor_dtindex_BMonthEndx2(self):
|
||||
DataFrame(self.d)
|
||||
|
||||
def get_period_count(self, start_date, off):
|
||||
self.ten_offsets_in_days = ((start_date + (off * 10)) - start_date).days
|
||||
if (self.ten_offsets_in_days == 0):
|
||||
return 1000
|
||||
else:
|
||||
return min((9 * ((Timestamp.max - start_date).days // self.ten_offsets_in_days)), 1000)
|
||||
|
||||
def get_index_for_offset(self, off):
|
||||
self.start_date = Timestamp('1/1/1900')
|
||||
return date_range(self.start_date, periods=min(1000, self.get_period_count(self.start_date, off)), freq=off)
|
||||
|
||||
|
||||
class frame_ctor_dtindex_BQuarterBeginx1(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.idx = self.get_index_for_offset(BQuarterBegin(1, **{}))
|
||||
self.df = DataFrame(np.random.randn(len(self.idx), 10), index=self.idx)
|
||||
self.d = dict([(col, self.df[col]) for col in self.df.columns])
|
||||
|
||||
def time_frame_ctor_dtindex_BQuarterBeginx1(self):
|
||||
DataFrame(self.d)
|
||||
|
||||
def get_period_count(self, start_date, off):
|
||||
self.ten_offsets_in_days = ((start_date + (off * 10)) - start_date).days
|
||||
if (self.ten_offsets_in_days == 0):
|
||||
return 1000
|
||||
else:
|
||||
return min((9 * ((Timestamp.max - start_date).days // self.ten_offsets_in_days)), 1000)
|
||||
|
||||
def get_index_for_offset(self, off):
|
||||
self.start_date = Timestamp('1/1/1900')
|
||||
return date_range(self.start_date, periods=min(1000, self.get_period_count(self.start_date, off)), freq=off)
|
||||
|
||||
|
||||
class frame_ctor_dtindex_BQuarterBeginx2(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.idx = self.get_index_for_offset(BQuarterBegin(2, **{}))
|
||||
self.df = DataFrame(np.random.randn(len(self.idx), 10), index=self.idx)
|
||||
self.d = dict([(col, self.df[col]) for col in self.df.columns])
|
||||
|
||||
def time_frame_ctor_dtindex_BQuarterBeginx2(self):
|
||||
DataFrame(self.d)
|
||||
|
||||
def get_period_count(self, start_date, off):
|
||||
self.ten_offsets_in_days = ((start_date + (off * 10)) - start_date).days
|
||||
if (self.ten_offsets_in_days == 0):
|
||||
return 1000
|
||||
else:
|
||||
return min((9 * ((Timestamp.max - start_date).days // self.ten_offsets_in_days)), 1000)
|
||||
|
||||
def get_index_for_offset(self, off):
|
||||
self.start_date = Timestamp('1/1/1900')
|
||||
return date_range(self.start_date, periods=min(1000, self.get_period_count(self.start_date, off)), freq=off)
|
||||
|
||||
|
||||
class frame_ctor_dtindex_BQuarterEndx1(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.idx = self.get_index_for_offset(BQuarterEnd(1, **{}))
|
||||
self.df = DataFrame(np.random.randn(len(self.idx), 10), index=self.idx)
|
||||
self.d = dict([(col, self.df[col]) for col in self.df.columns])
|
||||
|
||||
def time_frame_ctor_dtindex_BQuarterEndx1(self):
|
||||
DataFrame(self.d)
|
||||
|
||||
def get_period_count(self, start_date, off):
|
||||
self.ten_offsets_in_days = ((start_date + (off * 10)) - start_date).days
|
||||
if (self.ten_offsets_in_days == 0):
|
||||
return 1000
|
||||
else:
|
||||
return min((9 * ((Timestamp.max - start_date).days // self.ten_offsets_in_days)), 1000)
|
||||
|
||||
def get_index_for_offset(self, off):
|
||||
self.start_date = Timestamp('1/1/1900')
|
||||
return date_range(self.start_date, periods=min(1000, self.get_period_count(self.start_date, off)), freq=off)
|
||||
|
||||
|
||||
class frame_ctor_dtindex_BQuarterEndx2(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.idx = self.get_index_for_offset(BQuarterEnd(2, **{}))
|
||||
self.df = DataFrame(np.random.randn(len(self.idx), 10), index=self.idx)
|
||||
self.d = dict([(col, self.df[col]) for col in self.df.columns])
|
||||
|
||||
def time_frame_ctor_dtindex_BQuarterEndx2(self):
|
||||
DataFrame(self.d)
|
||||
|
||||
def get_period_count(self, start_date, off):
|
||||
self.ten_offsets_in_days = ((start_date + (off * 10)) - start_date).days
|
||||
if (self.ten_offsets_in_days == 0):
|
||||
return 1000
|
||||
else:
|
||||
return min((9 * ((Timestamp.max - start_date).days // self.ten_offsets_in_days)), 1000)
|
||||
|
||||
def get_index_for_offset(self, off):
|
||||
self.start_date = Timestamp('1/1/1900')
|
||||
return date_range(self.start_date, periods=min(1000, self.get_period_count(self.start_date, off)), freq=off)
|
||||
|
||||
|
||||
class frame_ctor_dtindex_BYearBeginx1(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.idx = self.get_index_for_offset(BYearBegin(1, **{}))
|
||||
self.df = DataFrame(np.random.randn(len(self.idx), 10), index=self.idx)
|
||||
self.d = dict([(col, self.df[col]) for col in self.df.columns])
|
||||
|
||||
def time_frame_ctor_dtindex_BYearBeginx1(self):
|
||||
DataFrame(self.d)
|
||||
|
||||
def get_period_count(self, start_date, off):
|
||||
self.ten_offsets_in_days = ((start_date + (off * 10)) - start_date).days
|
||||
if (self.ten_offsets_in_days == 0):
|
||||
return 1000
|
||||
else:
|
||||
return min((9 * ((Timestamp.max - start_date).days // self.ten_offsets_in_days)), 1000)
|
||||
|
||||
def get_index_for_offset(self, off):
|
||||
self.start_date = Timestamp('1/1/1900')
|
||||
return date_range(self.start_date, periods=min(1000, self.get_period_count(self.start_date, off)), freq=off)
|
||||
|
||||
|
||||
class frame_ctor_dtindex_BYearBeginx2(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.idx = self.get_index_for_offset(BYearBegin(2, **{}))
|
||||
self.df = DataFrame(np.random.randn(len(self.idx), 10), index=self.idx)
|
||||
self.d = dict([(col, self.df[col]) for col in self.df.columns])
|
||||
|
||||
def time_frame_ctor_dtindex_BYearBeginx2(self):
|
||||
DataFrame(self.d)
|
||||
|
||||
def get_period_count(self, start_date, off):
|
||||
self.ten_offsets_in_days = ((start_date + (off * 10)) - start_date).days
|
||||
if (self.ten_offsets_in_days == 0):
|
||||
return 1000
|
||||
else:
|
||||
return min((9 * ((Timestamp.max - start_date).days // self.ten_offsets_in_days)), 1000)
|
||||
|
||||
def get_index_for_offset(self, off):
|
||||
self.start_date = Timestamp('1/1/1900')
|
||||
return date_range(self.start_date, periods=min(1000, self.get_period_count(self.start_date, off)), freq=off)
|
||||
|
||||
|
||||
class frame_ctor_dtindex_BYearEndx1(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.idx = self.get_index_for_offset(BYearEnd(1, **{}))
|
||||
self.df = DataFrame(np.random.randn(len(self.idx), 10), index=self.idx)
|
||||
self.d = dict([(col, self.df[col]) for col in self.df.columns])
|
||||
|
||||
def time_frame_ctor_dtindex_BYearEndx1(self):
|
||||
DataFrame(self.d)
|
||||
|
||||
def get_period_count(self, start_date, off):
|
||||
self.ten_offsets_in_days = ((start_date + (off * 10)) - start_date).days
|
||||
if (self.ten_offsets_in_days == 0):
|
||||
return 1000
|
||||
else:
|
||||
return min((9 * ((Timestamp.max - start_date).days // self.ten_offsets_in_days)), 1000)
|
||||
|
||||
def get_index_for_offset(self, off):
|
||||
self.start_date = Timestamp('1/1/1900')
|
||||
return date_range(self.start_date, periods=min(1000, self.get_period_count(self.start_date, off)), freq=off)
|
||||
|
||||
|
||||
class frame_ctor_dtindex_BYearEndx2(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.idx = self.get_index_for_offset(BYearEnd(2, **{}))
|
||||
self.df = DataFrame(np.random.randn(len(self.idx), 10), index=self.idx)
|
||||
self.d = dict([(col, self.df[col]) for col in self.df.columns])
|
||||
|
||||
def time_frame_ctor_dtindex_BYearEndx2(self):
|
||||
DataFrame(self.d)
|
||||
|
||||
def get_period_count(self, start_date, off):
|
||||
self.ten_offsets_in_days = ((start_date + (off * 10)) - start_date).days
|
||||
if (self.ten_offsets_in_days == 0):
|
||||
return 1000
|
||||
else:
|
||||
return min((9 * ((Timestamp.max - start_date).days // self.ten_offsets_in_days)), 1000)
|
||||
|
||||
def get_index_for_offset(self, off):
|
||||
self.start_date = Timestamp('1/1/1900')
|
||||
return date_range(self.start_date, periods=min(1000, self.get_period_count(self.start_date, off)), freq=off)
|
||||
|
||||
|
||||
class frame_ctor_dtindex_BusinessDayx1(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.idx = self.get_index_for_offset(BusinessDay(1, **{}))
|
||||
self.df = DataFrame(np.random.randn(len(self.idx), 10), index=self.idx)
|
||||
self.d = dict([(col, self.df[col]) for col in self.df.columns])
|
||||
|
||||
def time_frame_ctor_dtindex_BusinessDayx1(self):
|
||||
DataFrame(self.d)
|
||||
|
||||
def get_period_count(self, start_date, off):
|
||||
self.ten_offsets_in_days = ((start_date + (off * 10)) - start_date).days
|
||||
if (self.ten_offsets_in_days == 0):
|
||||
return 1000
|
||||
else:
|
||||
return min((9 * ((Timestamp.max - start_date).days // self.ten_offsets_in_days)), 1000)
|
||||
|
||||
def get_index_for_offset(self, off):
|
||||
self.start_date = Timestamp('1/1/1900')
|
||||
return date_range(self.start_date, periods=min(1000, self.get_period_count(self.start_date, off)), freq=off)
|
||||
|
||||
|
||||
class frame_ctor_dtindex_BusinessDayx2(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.idx = self.get_index_for_offset(BusinessDay(2, **{}))
|
||||
self.df = DataFrame(np.random.randn(len(self.idx), 10), index=self.idx)
|
||||
self.d = dict([(col, self.df[col]) for col in self.df.columns])
|
||||
|
||||
def time_frame_ctor_dtindex_BusinessDayx2(self):
|
||||
DataFrame(self.d)
|
||||
|
||||
def get_period_count(self, start_date, off):
|
||||
self.ten_offsets_in_days = ((start_date + (off * 10)) - start_date).days
|
||||
if (self.ten_offsets_in_days == 0):
|
||||
return 1000
|
||||
else:
|
||||
return min((9 * ((Timestamp.max - start_date).days // self.ten_offsets_in_days)), 1000)
|
||||
|
||||
def get_index_for_offset(self, off):
|
||||
self.start_date = Timestamp('1/1/1900')
|
||||
return date_range(self.start_date, periods=min(1000, self.get_period_count(self.start_date, off)), freq=off)
|
||||
|
||||
|
||||
class frame_ctor_dtindex_BusinessHourx1(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.idx = self.get_index_for_offset(BusinessHour(1, **{}))
|
||||
self.df = DataFrame(np.random.randn(len(self.idx), 10), index=self.idx)
|
||||
self.d = dict([(col, self.df[col]) for col in self.df.columns])
|
||||
|
||||
def time_frame_ctor_dtindex_BusinessHourx1(self):
|
||||
DataFrame(self.d)
|
||||
|
||||
def get_period_count(self, start_date, off):
|
||||
self.ten_offsets_in_days = ((start_date + (off * 10)) - start_date).days
|
||||
if (self.ten_offsets_in_days == 0):
|
||||
return 1000
|
||||
else:
|
||||
return min((9 * ((Timestamp.max - start_date).days // self.ten_offsets_in_days)), 1000)
|
||||
|
||||
def get_index_for_offset(self, off):
|
||||
self.start_date = Timestamp('1/1/1900')
|
||||
return date_range(self.start_date, periods=min(1000, self.get_period_count(self.start_date, off)), freq=off)
|
||||
|
||||
|
||||
class frame_ctor_dtindex_BusinessHourx2(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.idx = self.get_index_for_offset(BusinessHour(2, **{}))
|
||||
self.df = DataFrame(np.random.randn(len(self.idx), 10), index=self.idx)
|
||||
self.d = dict([(col, self.df[col]) for col in self.df.columns])
|
||||
|
||||
def time_frame_ctor_dtindex_BusinessHourx2(self):
|
||||
DataFrame(self.d)
|
||||
|
||||
def get_period_count(self, start_date, off):
|
||||
self.ten_offsets_in_days = ((start_date + (off * 10)) - start_date).days
|
||||
if (self.ten_offsets_in_days == 0):
|
||||
return 1000
|
||||
else:
|
||||
return min((9 * ((Timestamp.max - start_date).days // self.ten_offsets_in_days)), 1000)
|
||||
|
||||
def get_index_for_offset(self, off):
|
||||
self.start_date = Timestamp('1/1/1900')
|
||||
return date_range(self.start_date, periods=min(1000, self.get_period_count(self.start_date, off)), freq=off)
|
||||
|
||||
|
||||
class frame_ctor_dtindex_CBMonthBeginx1(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.idx = self.get_index_for_offset(CBMonthBegin(1, **{}))
|
||||
self.df = DataFrame(np.random.randn(len(self.idx), 10), index=self.idx)
|
||||
self.d = dict([(col, self.df[col]) for col in self.df.columns])
|
||||
|
||||
def time_frame_ctor_dtindex_CBMonthBeginx1(self):
|
||||
DataFrame(self.d)
|
||||
|
||||
def get_period_count(self, start_date, off):
|
||||
self.ten_offsets_in_days = ((start_date + (off * 10)) - start_date).days
|
||||
if (self.ten_offsets_in_days == 0):
|
||||
return 1000
|
||||
else:
|
||||
return min((9 * ((Timestamp.max - start_date).days // self.ten_offsets_in_days)), 1000)
|
||||
|
||||
def get_index_for_offset(self, off):
|
||||
self.start_date = Timestamp('1/1/1900')
|
||||
return date_range(self.start_date, periods=min(1000, self.get_period_count(self.start_date, off)), freq=off)
|
||||
|
||||
|
||||
class frame_ctor_dtindex_CBMonthBeginx2(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.idx = self.get_index_for_offset(CBMonthBegin(2, **{}))
|
||||
self.df = DataFrame(np.random.randn(len(self.idx), 10), index=self.idx)
|
||||
self.d = dict([(col, self.df[col]) for col in self.df.columns])
|
||||
|
||||
def time_frame_ctor_dtindex_CBMonthBeginx2(self):
|
||||
DataFrame(self.d)
|
||||
|
||||
def get_period_count(self, start_date, off):
|
||||
self.ten_offsets_in_days = ((start_date + (off * 10)) - start_date).days
|
||||
if (self.ten_offsets_in_days == 0):
|
||||
return 1000
|
||||
else:
|
||||
return min((9 * ((Timestamp.max - start_date).days // self.ten_offsets_in_days)), 1000)
|
||||
|
||||
def get_index_for_offset(self, off):
|
||||
self.start_date = Timestamp('1/1/1900')
|
||||
return date_range(self.start_date, periods=min(1000, self.get_period_count(self.start_date, off)), freq=off)
|
||||
|
||||
|
||||
class frame_ctor_dtindex_CBMonthEndx1(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.idx = self.get_index_for_offset(CBMonthEnd(1, **{}))
|
||||
self.df = DataFrame(np.random.randn(len(self.idx), 10), index=self.idx)
|
||||
self.d = dict([(col, self.df[col]) for col in self.df.columns])
|
||||
|
||||
def time_frame_ctor_dtindex_CBMonthEndx1(self):
|
||||
DataFrame(self.d)
|
||||
|
||||
def get_period_count(self, start_date, off):
|
||||
self.ten_offsets_in_days = ((start_date + (off * 10)) - start_date).days
|
||||
if (self.ten_offsets_in_days == 0):
|
||||
return 1000
|
||||
else:
|
||||
return min((9 * ((Timestamp.max - start_date).days // self.ten_offsets_in_days)), 1000)
|
||||
|
||||
def get_index_for_offset(self, off):
|
||||
self.start_date = Timestamp('1/1/1900')
|
||||
return date_range(self.start_date, periods=min(1000, self.get_period_count(self.start_date, off)), freq=off)
|
||||
|
||||
|
||||
class frame_ctor_dtindex_CBMonthEndx2(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.idx = self.get_index_for_offset(CBMonthEnd(2, **{}))
|
||||
self.df = DataFrame(np.random.randn(len(self.idx), 10), index=self.idx)
|
||||
self.d = dict([(col, self.df[col]) for col in self.df.columns])
|
||||
|
||||
def time_frame_ctor_dtindex_CBMonthEndx2(self):
|
||||
DataFrame(self.d)
|
||||
|
||||
def get_period_count(self, start_date, off):
|
||||
self.ten_offsets_in_days = ((start_date + (off * 10)) - start_date).days
|
||||
if (self.ten_offsets_in_days == 0):
|
||||
return 1000
|
||||
else:
|
||||
return min((9 * ((Timestamp.max - start_date).days // self.ten_offsets_in_days)), 1000)
|
||||
|
||||
def get_index_for_offset(self, off):
|
||||
self.start_date = Timestamp('1/1/1900')
|
||||
return date_range(self.start_date, periods=min(1000, self.get_period_count(self.start_date, off)), freq=off)
|
||||
|
||||
|
||||
class frame_ctor_dtindex_CDayx1(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.idx = self.get_index_for_offset(CDay(1, **{}))
|
||||
self.df = DataFrame(np.random.randn(len(self.idx), 10), index=self.idx)
|
||||
self.d = dict([(col, self.df[col]) for col in self.df.columns])
|
||||
|
||||
def time_frame_ctor_dtindex_CDayx1(self):
|
||||
DataFrame(self.d)
|
||||
|
||||
def get_period_count(self, start_date, off):
|
||||
self.ten_offsets_in_days = ((start_date + (off * 10)) - start_date).days
|
||||
if (self.ten_offsets_in_days == 0):
|
||||
return 1000
|
||||
else:
|
||||
return min((9 * ((Timestamp.max - start_date).days // self.ten_offsets_in_days)), 1000)
|
||||
|
||||
def get_index_for_offset(self, off):
|
||||
self.start_date = Timestamp('1/1/1900')
|
||||
return date_range(self.start_date, periods=min(1000, self.get_period_count(self.start_date, off)), freq=off)
|
||||
|
||||
|
||||
class frame_ctor_dtindex_CDayx2(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.idx = self.get_index_for_offset(CDay(2, **{}))
|
||||
self.df = DataFrame(np.random.randn(len(self.idx), 10), index=self.idx)
|
||||
self.d = dict([(col, self.df[col]) for col in self.df.columns])
|
||||
|
||||
def time_frame_ctor_dtindex_CDayx2(self):
|
||||
DataFrame(self.d)
|
||||
|
||||
def get_period_count(self, start_date, off):
|
||||
self.ten_offsets_in_days = ((start_date + (off * 10)) - start_date).days
|
||||
if (self.ten_offsets_in_days == 0):
|
||||
return 1000
|
||||
else:
|
||||
return min((9 * ((Timestamp.max - start_date).days // self.ten_offsets_in_days)), 1000)
|
||||
|
||||
def get_index_for_offset(self, off):
|
||||
self.start_date = Timestamp('1/1/1900')
|
||||
return date_range(self.start_date, periods=min(1000, self.get_period_count(self.start_date, off)), freq=off)
|
||||
|
||||
|
||||
class frame_ctor_dtindex_CustomBusinessDayx1(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.idx = self.get_index_for_offset(CustomBusinessDay(1, **{}))
|
||||
self.df = DataFrame(np.random.randn(len(self.idx), 10), index=self.idx)
|
||||
self.d = dict([(col, self.df[col]) for col in self.df.columns])
|
||||
|
||||
def time_frame_ctor_dtindex_CustomBusinessDayx1(self):
|
||||
DataFrame(self.d)
|
||||
|
||||
def get_period_count(self, start_date, off):
|
||||
self.ten_offsets_in_days = ((start_date + (off * 10)) - start_date).days
|
||||
if (self.ten_offsets_in_days == 0):
|
||||
return 1000
|
||||
else:
|
||||
return min((9 * ((Timestamp.max - start_date).days // self.ten_offsets_in_days)), 1000)
|
||||
|
||||
def get_index_for_offset(self, off):
|
||||
self.start_date = Timestamp('1/1/1900')
|
||||
return date_range(self.start_date, periods=min(1000, self.get_period_count(self.start_date, off)), freq=off)
|
||||
|
||||
|
||||
class frame_ctor_dtindex_CustomBusinessDayx2(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.idx = self.get_index_for_offset(CustomBusinessDay(2, **{}))
|
||||
self.df = DataFrame(np.random.randn(len(self.idx), 10), index=self.idx)
|
||||
self.d = dict([(col, self.df[col]) for col in self.df.columns])
|
||||
|
||||
def time_frame_ctor_dtindex_CustomBusinessDayx2(self):
|
||||
DataFrame(self.d)
|
||||
|
||||
def get_period_count(self, start_date, off):
|
||||
self.ten_offsets_in_days = ((start_date + (off * 10)) - start_date).days
|
||||
if (self.ten_offsets_in_days == 0):
|
||||
return 1000
|
||||
else:
|
||||
return min((9 * ((Timestamp.max - start_date).days // self.ten_offsets_in_days)), 1000)
|
||||
|
||||
def get_index_for_offset(self, off):
|
||||
self.start_date = Timestamp('1/1/1900')
|
||||
return date_range(self.start_date, periods=min(1000, self.get_period_count(self.start_date, off)), freq=off)
|
||||
|
||||
|
||||
class frame_ctor_dtindex_DateOffsetx1(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.idx = self.get_index_for_offset(DateOffset(1, **{}))
|
||||
self.df = DataFrame(np.random.randn(len(self.idx), 10), index=self.idx)
|
||||
self.d = dict([(col, self.df[col]) for col in self.df.columns])
|
||||
|
||||
def time_frame_ctor_dtindex_DateOffsetx1(self):
|
||||
DataFrame(self.d)
|
||||
|
||||
def get_period_count(self, start_date, off):
|
||||
self.ten_offsets_in_days = ((start_date + (off * 10)) - start_date).days
|
||||
if (self.ten_offsets_in_days == 0):
|
||||
return 1000
|
||||
else:
|
||||
return min((9 * ((Timestamp.max - start_date).days // self.ten_offsets_in_days)), 1000)
|
||||
|
||||
def get_index_for_offset(self, off):
|
||||
self.start_date = Timestamp('1/1/1900')
|
||||
return date_range(self.start_date, periods=min(1000, self.get_period_count(self.start_date, off)), freq=off)
|
||||
|
||||
|
||||
class frame_ctor_dtindex_DateOffsetx2(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.idx = self.get_index_for_offset(DateOffset(2, **{}))
|
||||
self.df = DataFrame(np.random.randn(len(self.idx), 10), index=self.idx)
|
||||
self.d = dict([(col, self.df[col]) for col in self.df.columns])
|
||||
|
||||
def time_frame_ctor_dtindex_DateOffsetx2(self):
|
||||
DataFrame(self.d)
|
||||
|
||||
|