首页 > 解决方案 > 如何向 pandas.Series.apply 添加额外的参数

问题描述

这个问题是关于这个问题的答案:https ://stackoverflow.com/a/49237721/13757785 。

Why does the args parameter in df.apply(some_func, args=('DOG', ), axis=1) contain that extra comma? I looked at the documentation page https://pandas.pydata.org/docs/reference/api/pandas.Series.apply.html, but it does not explicitly give an example with a function with multiple parameters or the usage of args in general.

My only guess would be that the comma is required to fulfill the 'tuple' python-type, but can anyone verify or disprove that?

标签: pythonpandas

解决方案


推荐阅读