我已经开始在 pandas 1.0.1 中使用 StringDtype 我知道它被认为是实验性的,但是在包含 NaN 的字符串类型列上使用替换时遇到了问题。
例如:
df = pd.DataFrame({'a': ['a', 'b', 'c', None]}, dtype='string')
df.replace({'c': 'e'})
上述结果:
TypeError: Cannot compare types 'ndarray(dtype=object)' and 'str'
这可能是一个错误还是我做错了什么?