0%

pandas.apply()的axis参数

1
DataFrame.apply(func, axis=0, broadcast=None, raw=False, reduce=None, result_type=None, args=(), **kwds)

func : Function to be applied to each column or row. This function accepts a series and returns a series.

我们往往对 axis 搞不太清楚。

axis : Axis along which the function is applied in dataframe. Default value 0.

  • If value is 0 then it applies function to each column.
  • If value is 1 then it applies function to each row.

args : tuple / list of arguments to passed to function.