date rtn 0 2016-01-01 0.101536 1 2016-01-02 0.055109 2 2016-01-03 -0.163625 3 2016-01-04 0.086756 4 2016-01-05 0.035907 5 2016-01-06 0.047619 6 2016-01-07 0.018717 7 2016-01-08 -0.036290
这样子的 df
大佬帮帮忙,实在搞不出来了
1
neosfung 2018-09-28 21:12:13 +08:00
df['rtn'] = df['rtn'].apply(lambda x: 1 if x>0 else x)
|
2
jswangjieda 2018-09-28 21:40:14 +08:00
df.loc[df['rtn']>0,'rtn']=1
|
3
ddzzhen 2018-09-28 22:43:41 +08:00 via Android
直接改为 true,false 矩阵
|
4
lieh222 2018-09-29 08:38:47 +08:00
x = x**0
|
6
qianc1990 2018-09-29 15:32:59 +08:00
df['rtn'] = np.where(df['rtn']>0, 1, df['rtn'])
|