这就是我要犯的错误
TypeError Traceback (most recent call last)
Input In [141], in <cell line: 2>()
1 repl = {'Y':'1', 'N':'0'}
----> 2 prices_dataframe['col_state'] = prices_dataframe['col_state'].replace(repl, regex=True)
TypeError: 'bool' object is not subscriptable
这就是我试过的
repl = {'Y':'1','N':'0'} prices_dataframe‘’col_state‘=prices_dataframe’‘col_state’.替换(repl,regex=True)
发布于 2022-11-07 10:59:18
replace()
方法对字符串是唯一的,在某些时候,要替换的值是布尔值(真或假)。如果仍然想替换它,可以将值转换为字符串:
prices_dataframe['col_state'] = str(prices_dataframe['col_state']).replace(repl, regex=True)
https://stackoverflow.com/questions/74345210
复制相似问题