cand[~cand['Candidate Party'].str.contains("Democrat|Republican"), 'Candidate Party'] = "Other"我在上面的代码行中,如果不包含民主党或共和党作为子字符串,我想将候选人党值更改为其他值。但是,我得到了这个错误
TypeError: 'Series' objects are mutable, thus they cannot be hashed发布于 2020-12-17 11:01:44
我觉得你想要loc
cand.loc[~cand['Candidate Party'].str.contains("Democrat|Republican"),
'Candidate Party'] = "Other"https://stackoverflow.com/questions/65334105
复制相似问题