一个Pandas DataFrame对象,DataFrame大约有1300行,12列(例如:A,B,C,D ......),
#### df stands for above data object(Pandas.DataFrame)
def task(df):
t1 = time.time()
# param contains values use to compare with df value.
param = init_param()
#iter all rows
for x in range(len(df["A"])):
# statistical(df, param) get df value and do some statistical work
# eg:
# df["A"][x] > df["A"][x-1]
# df["B"][x] > param["f3"][x]
# df['A'][x] > param["f1"][x] and df['B'][x- 1] < param['f2'][
# index - 1]
# ...
flag = statistical(x, df, param)
print(flag)
print(time.time() - t1)
上面的task()函数将在一个大循环函数下执行。 EG:
for x in range(10000):
task()
我希望任务运行更有效率,我已经完成了一些测试用例,下面是最终结果列表。