Skip to content

Commit

Permalink
CLN: ASV period (#18932)
Browse files Browse the repository at this point in the history
  • Loading branch information
mroeschke authored and jreback committed Dec 26, 2017
1 parent 95e79a7 commit aa84e00
Showing 1 changed file with 22 additions and 57 deletions.
79 changes: 22 additions & 57 deletions asv_bench/benchmarks/period.py
Original file line number Diff line number Diff line change
@@ -1,61 +1,24 @@
import pandas as pd
from pandas import Series, Period, PeriodIndex, date_range
from pandas import (DataFrame, Series, Period, PeriodIndex, date_range,
period_range)


class PeriodProperties(object):
params = ['M', 'min']
param_names = ['freq']

def setup(self, freq):
self.per = Period('2012-06-01', freq=freq)

def time_year(self, freq):
self.per.year

def time_month(self, freq):
self.per.month

def time_day(self, freq):
self.per.day

def time_hour(self, freq):
self.per.hour

def time_minute(self, freq):
self.per.minute

def time_second(self, freq):
self.per.second

def time_is_leap_year(self, freq):
self.per.is_leap_year

def time_quarter(self, freq):
self.per.quarter
params = (['M', 'min'],
['year', 'month', 'day', 'hour', 'minute', 'second',
'is_leap_year', 'quarter', 'qyear', 'week', 'daysinmonth',
'dayofweek', 'dayofyear', 'start_time', 'end_time'])
param_names = ['freq', 'attr']

def time_qyear(self, freq):
self.per.qyear

def time_week(self, freq):
self.per.week

def time_daysinmonth(self, freq):
self.per.daysinmonth

def time_dayofweek(self, freq):
self.per.dayofweek

def time_dayofyear(self, freq):
self.per.dayofyear

def time_start_time(self, freq):
self.per.start_time
def setup(self, freq, attr):
self.per = Period('2012-06-01', freq=freq)

def time_end_time(self, freq):
self.per.end_time
def time_property(self, freq, attr):
getattr(self.per, attr)


class PeriodUnaryMethods(object):

params = ['M', 'min']
param_names = ['freq']

Expand All @@ -73,6 +36,7 @@ def time_asfreq(self, freq):


class PeriodIndexConstructor(object):

goal_time = 0.2

params = ['D']
Expand All @@ -90,19 +54,19 @@ def time_from_pydatetime(self, freq):


class DataFramePeriodColumn(object):

goal_time = 0.2

def setup_cache(self):
rng = pd.period_range(start='1/1/1990', freq='S', periods=20000)
df = pd.DataFrame(index=range(len(rng)))
return rng, df
def setup(self):
self.rng = period_range(start='1/1/1990', freq='S', periods=20000)
self.df = DataFrame(index=range(len(self.rng)))

def time_setitem_period_column(self, tup):
rng, df = tup
df['col'] = rng
def time_setitem_period_column(self):
self.df['col'] = self.rng


class Algorithms(object):

goal_time = 0.2

params = ['index', 'series']
Expand All @@ -125,6 +89,7 @@ def time_value_counts(self, typ):


class Indexing(object):

goal_time = 0.2

def setup(self):
Expand All @@ -145,7 +110,7 @@ def time_series_loc(self):
self.series.loc[self.period]

def time_align(self):
pd.DataFrame({'a': self.series, 'b': self.series[:500]})
DataFrame({'a': self.series, 'b': self.series[:500]})

def time_intersection(self):
self.index[:750].intersection(self.index[250:])

0 comments on commit aa84e00

Please sign in to comment.