【问题标题】:how can I return column that i already deleted in dataframe pandas如何返回已在数据框 pandas 中删除的列
【发布时间】:2020-12-12 10:57:15
【问题描述】:

使用df.drop(),我从df 中删除了“ID”列,现在我想返回该列。

df.drop('ID', axis=1, inplace=True)
df
# shows me df without ID column

我应该使用什么方法?

【问题讨论】:

  • 在这种情况下,我将该列保存在变量中,然后删除原始列。
  • 您无法找回被inplace=True删除的列。

标签: python pandas dataframe return drop


【解决方案1】:

发现你需要做的就是重新加载第一个导入df的命令:)

【讨论】:

    猜你喜欢
    • 2021-03-09
    • 1970-01-01
    • 2019-06-07
    • 2020-12-14
    • 2013-01-17
    • 1970-01-01
    • 2012-06-07
    • 2021-12-06
    相关资源
    最近更新 更多