2015-12-24 33 views

回答

1

你可以将参数传递到apply

df.apply(pd.Series.interpolate, args=('nearest',)) 

df.apply(pd.Series.interpolate, method='nearest') 
+0

安东,为什么在args() – kevinL

+0

@kevinL中的“最接近”之后有一个“,”,使它成为元组,如果你通过'('nearest')'它将解释为7个参数,因为它会尝试分割该字符串。其实你可以尝试两种方式,你会看到。 'type(('''))'和'type(('''))'会相应地给出'str'和'tuple'。 –

+0

非常感谢 – kevinL

1

您需要提供一个函数,并挑选轴线(0柱):

df.apply(lambda a: a.interpolate(method='nearest'), axis=0)