代码:
var weekDateStr = [];
var date = moment().startOf('week');
for(var i = 0; i < 7; i++) {
console.log(date.format('ddd, MMM Do'));
weekDateStr.push(date.format('ddd, MMM Do'));
date = date.adḍ̣(1, 'day')
}
console.log(weekDateStr);
当我在jupyter notbook中运行def combCreate(grp,num):
d = chain(*(map(lambda x: (combinations(x,num)),grp)))
return set(d)
# Comb DataFrame abt Freq & occured date
def combFrame(grp):
arr = df.loc[:,'date':'6th'].values
t = []
cnt = []
for i in grp:
tmp_cnt = 0
tmp_time = []
for v,date in zip(arr[:,1:],arr[:,0]):
if set(i)<=set(v):
tmp_time.append(date)
tmp_cnt=tmp_cnt+1
t.append(tuple(tmp_time))
cnt.append(tmp_cnt)
df_comb = pd.DataFrame({'cnt':cnt,'time':t},index=grp)
return df_comb
t_arr = df.loc[:,'1st':'6th'].values[:5]
comb_create = combCreate(t_arr,4)
%lprun -f combFrame(comb_create)
时,除了%lprun
之外什么也看不见。我不知道这意味着什么。
UserWarning
希望:
解决它并解释原因。
答案 0 :(得分:1)
我错过了在%lprun
之后添加功能名称。正确答案是
%lprun -f combFrame combFrame(comb_create)
Total time: 0.630435 s
File: <ipython-input-340-ea2ba2ae7d55>
Function: combFrame at line 10
Line # Hits Time Per Hit % Time Line Contents
==============================================================
10 def combFrame(grp):
11 1 32015.0 32015.0 5.1 arr = df.loc[:,'date':'6th'].values
12 1 4.0 4.0 0.0 t = []
13 1 2.0 2.0 0.0 cnt = []
14 76 420.0 5.5 0.1 for i in grp:
15 75 59.0 0.8 0.0 tmp_cnt = 0
16 75 88.0 1.2 0.0 tmp_time = []
17 170025 157326.0 0.9 25.0 for v,date in zip(arr[:,1:],arr[:,0]):
18 169950 428583.0 2.5 68.0 if set(i)<=set(v):
19 155 236.0 1.5 0.0 tmp_time.append(date)
20 155 158.0 1.0 0.0 tmp_cnt=tmp_cnt+1
21 75 586.0 7.8 0.1 t.append(tuple(tmp_time))
22 75 107.0 1.4 0.0 cnt.append(tmp_cnt)
23 1 10849.0 10849.0 1.7 df_comb = pd.DataFrame({'cnt':cnt,'time':t},index=grp)
24 1 2.0 2.0 0.0 return df_comb