我似乎无法从Apply函数内部更新数据框上的行
import pandas as pd
df = pd.DataFrame({'filename':['test0.dat', 'test2.dat'],
'm':[12, 13],
'n':[None, None]})
data = {'filename':'test2.dat', 'n':16}
def update_vals(row, data=data):
if row.filename == data['filename']:
row.n = data['n']
return row
df.apply(update_vals, axis=1)