【问题标题】:Pandas - How can I make every value within a column NaN?Pandas - 我怎样才能使列 NaN 中的每个值?
【发布时间】:2014-10-15 15:53:04
【问题描述】:

我想从我的数据框中的列中清除所有数据,但保持数据框完全相同。

在 Excel 中与此等效的是选择标题下方一列中的所有数据,然后右键单击“清除内容”。

我试过了:

test = df.replace(to_replace=df('Column Name'), value=NaN)

但出现错误说明:

TypeError: 'DataFrame' object is not callable

我不知道这意味着什么,也不知道如何考虑更改我的代码。

【问题讨论】:

  • 为什么不只是df['Column Name'] = NaN`?

标签: python pandas dataframe


【解决方案1】:

只要df['Column Name'] = NaN,simples

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-10-29
    • 1970-01-01
    • 2018-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多