【问题标题】:df.set_index=("Neighbourhood",inplace=True) giving me SyntaxError: invalid syntaxdf.set_index=("Neighbourhood",inplace=True) 给我 SyntaxError: invalid syntax
【发布时间】:2019-08-14 10:55:39
【问题描述】:

我之前的所有代码都运行良好。

只有当我尝试将索引设置为特定列(如下面的代码所示)时,才会遇到错误。

老实说,这种方法以前也有用过,我还没有找到任何其他方法来做同样的事情。

df.set_index=("Neighbourhood",inplace=True)

错误信息:

文件“”,第 1 行 df.set_index=("社区",inplace=True) ^ SyntaxError: 无效语法

【问题讨论】:

    标签: python python-3.x indexing methods


    【解决方案1】:

    set_index是一个函数,你需要调用它。

    试试df.set_index("Neighbourhood",inplace=True)(不带=

    【讨论】:

      猜你喜欢
      • 2021-12-11
      • 2022-12-12
      • 2015-06-10
      • 1970-01-01
      • 1970-01-01
      • 2019-07-29
      • 2022-12-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多