如何为travel_min列中具有空值的所有3行分配值match_time。travel_min是浮点数。
我收到以下错误:
TypeError:'str'对象不支持项目分配
null_df = data[data['travel_min'].isnull()]
match_time = data.loc[data['train_station_id']==20026]['travel_min']
for row in null_df:
row['travel_min'] = match_time
答案 0 :(得分:1)
Start Outer Try
Start Inner Try
Exception thrown: 'System.Exception' in MyTestApp.exe
In Inner Finally
In outer catch
In outer finally
无需切片数据帧或使用Python级的match_time = data.loc[data['train_station_id']==20026, 'travel_min'].iat[0]
df['travel_min'] = df['travel_min'].fillna(match_time)
循环。