python-3.x - 类型错误 : drop() got multiple values for argument 'axis' when dropping multiple columns

标签 python-3.x pandas

我有一个名为“tips”的数据框,我试图在其中删除两列 tiphigher_than_15pct_true,如下所示:

X = tips.drop('tip','higher_than_15pct_True', axis = 1)

这会导致以下错误:

TypeError: drop() got multiple values for argument 'axis'

我该如何解决这个问题?

最佳答案

根据 Pandas documentation for DataFrame.drop ,如果有多个列,则需要传递单个标签或列表:

X = tips.drop(['tip','higher_than_15pct_True'], axis = 1)

不幸的是,TypeError 最终变得非常神秘,与手头的实际问题无关。

关于python-3.x - 类型错误 : drop() got multiple values for argument 'axis' when dropping multiple columns,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57846537/

相关文章:

python - 多个 np.where 减少匹配

python - 遍历列以将每个列与 Python 中的特定列进行比较

Python:无法使用请求模块进行身份验证

python - 将 RowNumber 添加到 Dict 列表

Python2 在 Pandas DataFrame 中选择数据的速度比 Python3 快......为什么?

python / Pandas : Use lookup DataFrame + function to replace specific/null values in DataFrame

python - 将所有数值替换为 NaN Pandas

Python 3 : Insertion Sort comparisons counter

python - 将 Pandas 数据框列映射到字典

python - 如何连接目录中的所有 CSV,使用 Python 添加 CSV 名称作为列