简体   繁体   English

在 dataframe 类型错误中出现错误:“系列”对象是可变的,因此无法对其进行哈希处理

[英]Getting error in dataframe typeError: 'Series' objects are mutable, thus they cannot be hashed

I am trying to apply this operation on my dataframe df:我正在尝试在我的 dataframe df 上应用此操作:

df[df.a, 'b'] = df.c*df.b

where data types of a,b,c are:其中 a,b,c 的数据类型为:

a: bool
b: float64
c: float64

But I am getting the error TypeError: 'Series' objects are mutable, thus they cannot be hashed但我收到错误TypeError: 'Series' objects are mutable, thus they cannot be hashed

Is it happening because of na value present in column b or c?发生这种情况是因为 b 列或 c 中存在 na 值吗? If yes, is there a way to ignore the operation for na values?如果是,有没有办法忽略 na 值的操作?

Thanks.谢谢。

Please try use the loc accessor and it should be fine.请尝试使用loc访问器,它应该没问题。

df.loc[df.a,'b']=df.c*df.b

暂无
暂无

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

相关问题 类型错误:“系列”对象是可变的,因此它们不能被散列 - TypeError: 'Series' objects are mutable, thus they cannot be hashed TypeError:'DataFrame'对象是可变的,因此它们不能被散列 - TypeError: 'DataFrame' objects are mutable, thus they cannot be hashed 在pandas系列上使用apply方法获取TypeError'Series'对象是可变的,因此不能将它们散列 - Using apply method on pandas series getting TypeError 'Series' objects are mutable, thus they cannot be hashed TypeError: 'Series' 对象是可变的,因此不能对列进行哈希处理 - TypeError: 'Series' objects are mutable, thus they cannot be hashed problemwith column 如何修复 TypeError:'Series' 对象是可变的,因此它们不能被散列 - How to fix TypeError: 'Series' objects are mutable, thus they cannot be hashed 系列对象是可变的,因此它们不能在 Python pandas 数据帧上散列 - Series objects are mutable, thus they cannot be hashed on Python pandas dataframe 获取类型错误:“系列”对象是可变的,因此在使用 function 将列中的 int 转换为季节时,它们不能被散列 - Getting a TypeError: 'Series' objects are mutable, thus they cannot be hashed when using a function to convert a int in a column to a season 使用TensorFlow训练NN时发生错误:TypeError:'Series'对象是可变的,因此无法进行散列 - Error in training NN with TensorFlow: TypeError: 'Series' objects are mutable, thus they cannot be hashed 'Series'对象是可变的,因此它们不能在调用to_csv时出现散列错误 - 'Series' objects are mutable, thus they cannot be hashed error calling to_csv Pandas loc 错误:“系列”对象是可变的,因此它们不能被散列 - Pandas loc error: 'Series' objects are mutable, thus they cannot be hashed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM