简体   繁体   English

熊猫-如何在NaN列中实现每个值?

[英]Pandas - How can I make every value within a column NaN?

I want to clear all the data from a column within my dataframe but keep the dataframe exactly the same. 我想清除数据框内某列的所有数据,但保持数据框完全相同。

The Excel equivalent of this would be to select all the data in a column beneath the header and right-click "Clear Contents". Excel的等效方法是选择标题下一列中的所有数据,然后右键单击“清除内容”。

I tried this: 我尝试了这个:

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

but got an error stating: 但出现错误说明:

TypeError: 'DataFrame' object is not callable

I don't know what that means or how to think about changing my code. 我不知道这意味着什么,或者不知道如何更改代码。

只需df['Column Name'] = NaN简单

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何用不在熊猫系列中先前值某个范围内的NAN替换任何值? - How can I replace any value with an NAN that is not within a certain range of the previous value in a pandas series? 如何在熊猫数据框中用均值替换NaN值? - How can I replace NaN value with mean in a Pandas dataframe? 在Pandas中,我如何按键中的每N行进行分组,保存一列的最后一个值并根据该'set'中的所有行计算另一列? - In Pandas, how can I group by every N rows within a key, saving the last value of one column and calculating another based on all rows in that 'set'? 如何在 pandas python 中用 0 填充每列末尾的 nan? - How to fill the nan's at the end of every column with 0's in pandas python? 如何使用pandas替换具有不同随机值的列中的每个NaN? - How to replace every NaN in a column with different random values using pandas? 如何计算列值等于NaN或零? - How can I count if column value is equal to NaN or zero? 如何替换“对象”列中的 nan 值? - How can I replace a nan value in an "object" column? 如何将pandas列分配给其他列,或者如果为nan,则为默认值? - How to assign pandas column to other column, or default value if nan? 如果第 1 列 = 特定值且第 2 列 = NaN,如何删除 pandas 中的行? - How to drop row in pandas if column1 = certain value and column 2 = NaN? 如何为Pandas列中的每个元素分配一个列表(或系列)? - How can I assign a list (or series) to every element in column in Pandas?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM