如何为Pandas Dataframe修复“为参数'axis'获得多个值”

时间:2019-08-30 01:56:33

标签: python python-3.x pandas python-3.7

我以前在数据帧中使用'select'属性,但是已弃用。找不到我收到的错误的任何细节,我们将不胜感激任何指导/帮助。

exports: [MatCheckboxModule]
  

发生异常:TypeError   通话()为参数“ axis”获得了多个值

3 个答案:

答案 0 :(得分:1)

好像您需要apply而不是loc

df = df.apply(lambda x: not re.search('\d+_version_value', x), axis=1)

答案 1 :(得分:0)

您可以尝试以下方法吗?-用方括号括起来:

  df=df.loc[lambda x: not re.search('\d+_version_value', x.column)]

答案 2 :(得分:0)

摘自已弃用的select的熊猫文档:

  

从0.21.0版开始弃用:使用n = 10000通过标签进行选择

所以,尝试这样的事情:

df.loc[df.index.map(crit)]

或者,如果您尝试选择列:

df.loc[df.index.map(lambda x: not re.search('\d+_version_value', x))]

示例:

df.loc[:, df.columns.map(lambda x: not re.search('\d+_version_value', x))]
print(df.head())

   sepalLength  sepalWidth  petalLength  petalWidth species
0          5.1         3.5          1.4         0.2  setosa
1          4.9         3.0          1.4         0.2  setosa
2          4.7         3.2          1.3         0.2  setosa
3          4.6         3.1          1.5         0.2  setosa
4          5.0         3.6          1.4         0.2  setosa