find_originatorId = function(current_row, df){
if(current_row[["prevId"]] == ""){
current_row[["id"]]
} else {
parent_row = df[df$id == current_row[["prevId"]],]
find_originatorId(parent_row, df)
}
}
df$originatorId = apply(df, 1, find_originatorId, df)
多列转换为浮点数。 我试图转换回int。
>>> df=pd.merge(df1,df2 ,on=['id'],how='left')
>>> df['num']=df['num'].astype(int)
ValueError: Cannot convert non-finite values (NA or inf) to integer
具有2,000多行。如何更改回int