将向量粘贴到过滤后的数据框 pandas

时间:2021-05-09 18:39:15

标签: python pandas

我正在为以下代码行苦苦挣扎:

The server time is before the current time.

我试图做的是将过滤数据框“BusinessAZ”中“county”列中的现有值替换为向量“counties”中包含的值。

向量和过滤后的数据框 BusinessAZ 具有相同的长度。

这里有一个说明性的例子:

'BusinessAZ' 数据框 enter image description here

'counties' 向量

['copin', 'copin', 'copin']

我想用向量 'counties' 的值替换过滤数据框中的值 'Na' 和 'error'

BusinessAZ[(BusinessAZ['county']=='Na') | (BusinessAZ['county']=='error code')].loc[:,'county'] = counties

enter image description here

有谁知道如何解决这个问题。

如果您能帮助我,我将不胜感激。

亲切的问候

胡安C

0 个答案:

没有答案
相关问题