我有以下DataFrame由整数值组成的内容:df = pd.DataFrame(data=1, columns=['a','b'], index=[1,2,3]) a b1 1 12 1 13 1 1我想在单个单元格上设置缺失值,当我尝试时:df.at[1,'a'] = np.nan然后我得到这个异常:Traceback (most recent call last): File "<input>", line 1, in <module> File "pandas/core/indexing.py", line 2159, in __setitem__ self.obj._set_value(*key, takeable=self._takeable) File "pandas/core/frame.py", line 2582, in _set_value engine.set_value(series._values, index, value) File "pandas/_libs/index.pyx", line 124, in pandas._libs.index.IndexEngine.set_value File "pandas/_libs/index.pyx", line 133, in pandas._libs.index.IndexEngine.set_value File "pandas/_libs/index.pyx", line 570, in pandas._libs.index.convert_scalarValueError: Cannot assign nan to integer series
添加回答
举报
0/150
提交
取消