Python 使用更多参数应用(pd.Series.interpolate)

Python 使用更多参数应用(pd.Series.interpolate),python,pandas,Python,Pandas,我如何重写 df.apply(pd.Series.interpolate) 因此,它可以实现与 df.interpolate(method='nearest') 提前感谢。您需要提供一个函数,并选择轴(0表示列): 您可以将参数传递给: 或 安东,为什么在args()@kevinL中的'nearest'后面有一个“,”使其成为元组,如果您传递('nearest'),它将解释为7个参数,因为它将尝试拆分该字符串。事实上,你可以尝试两种方法,你会看到的type('a'))和type('a',)将

我如何重写

df.apply(pd.Series.interpolate)
因此,它可以实现与

df.interpolate(method='nearest')

提前感谢。

您需要提供一个函数,并选择轴(0表示列):


您可以将参数传递给:


安东,为什么在args()@kevinL中的'nearest'后面有一个“,”使其成为元组,如果您传递
('nearest')
,它将解释为7个参数,因为它将尝试拆分该字符串。事实上,你可以尝试两种方法,你会看到的
type('a'))
type('a',)
将相应地给出
str
tuple
df.apply(lambda a: a.interpolate(method='nearest'), axis=0)
df.apply(pd.Series.interpolate, args=('nearest',))
df.apply(pd.Series.interpolate, method='nearest')