2021
07-09
07-09
python eval 转换k m到乘法计算的操作
原数据lambda函数处理我之前写了各种ifsubstr函数,各种报错正确到热泪盈眶的函数data['Followers/Fans']=data['Followers/Fans'].str.replace('k|K','*1000').str.replace('m|M','*1000000').fillna('0')data['Followers/Fans']=data['Followers/Fans'].apply(eval)报错函数#deftrans(x):#x=str(x)#x=x.strip()#去除首尾空格#if(x[-1]=='k'orx[-1]=='K'):#returnfloat(x[0:-1])*...
继续阅读 >