Python 3.x pandas/_libs/index.pyx键错误:';美国';

Python 3.x pandas/_libs/index.pyx键错误:';美国';,python-3.x,pandas,Python 3.x,Pandas,我正在搜索一个名为“United States”的行索引,它给出了这个错误 当我尝试分配给新的数据帧时。但我能打印出来吗?有什么想法吗?谢谢 这会将KeyErrordf=df.loc[country.strip(),:]发送到_frame() 但是,我可以打印出来 打印(df.loc[country.strip(),:]到_frame()) 问题是数据, 我也有同样的问题,因为我的数据由整数和浮点组成 数组或矩阵只能有一种类型的数据 如果可以将数据更改为float或integer,则可以将其修复

我正在搜索一个名为“United States”的行索引,它给出了这个错误 当我尝试分配给新的数据帧时。但我能打印出来吗?有什么想法吗?谢谢

这会将KeyError
df=df.loc[country.strip(),:]发送到_frame()

但是,我可以打印出来
打印(df.loc[country.strip(),:]到_frame())

问题是数据, 我也有同样的问题,因为我的数据由整数和浮点组成 数组或矩阵只能有一种类型的数据 如果可以将数据更改为float或integer,则可以将其修复

我将原始excel文件更新为浮动,并另存为CSV(由于某些原因,它不会将我的文件更新为浮动),然后运行您的程序

希望能有帮助

It's clearly in the index: United States
Traceback (most recent call last):
  File "/Users/feiwhang/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 2646, in get_loc
    return self._engine.get_loc(key)
  File "pandas/_libs/index.pyx", line 111, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/index.pyx", line 133, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/index.pyx", line 163, in pandas._libs.index.IndexEngine._get_loc_duplicates
  File "pandas/_libs/index.pyx", line 180, in pandas._libs.index.IndexEngine._maybe_get_bool_indexer
KeyError: 'United States'
          United States
Confirmed          7783
Recovered             0
Death               118