Jupyter Notebook中的Python 3.x folium TraceBack错误

问题描述 投票:0回答:1

我是folium的新用户,但我正在尝试遵循另一位用户的代码。由于某种原因,这是行不通的,我只想确保它与我使用Jupyter笔记本电脑这一事实无关。

m = folium.Map(location=[0, 0], tiles='cartodbpositron',
               min_zoom=1, max_zoom=4, zoom_start=1)

for i in range(0, len(full_latest)):
    folium.Circle(
        location=[full_latest.iloc[i]['Lat'], full_latest.iloc[i]['Long']],
        color='crimson', 
        tooltip =   '<li><bold>Country : '+str(full_latest.iloc[i]['Country'])+
                    '<li><bold>Province : '+str(full_latest.iloc[i]['Province/State'])+
                    '<li><bold>Confirmed : '+str(full_latest.iloc[i]['Confirmed'])+
                    '<li><bold>Deaths : '+str(full_latest.iloc[i]['Deaths'])+
                    '<li><bold>Recovered : '+str(full_latest.iloc[i]['Recovered']),
        radius=int(full_latest.iloc[i]['Confirmed'])**1.1).add_to(m)
m

我正在学习数据科学,并检查了对熊猫中DataFrames的引用,但没有看到拼写错误。我已经咨询了我的导师,但仍然没有运气。这是错误输出:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
~\Anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_value(self, series, key)
   4735             try:
-> 4736                 return libindex.get_value_box(s, key)
   4737             except IndexError:

pandas\_libs\index.pyx in pandas._libs.index.get_value_box()

pandas\_libs\index.pyx in pandas._libs.index.get_value_at()

pandas\_libs\util.pxd in pandas._libs.util.get_value_at()

pandas\_libs\util.pxd in pandas._libs.util.validate_indexer()

TypeError: 'str' object cannot be interpreted as an integer

During handling of the above exception, another exception occurred:

KeyError                                  Traceback (most recent call last)
<ipython-input-21-4272891a2f02> in <module>
      6 for i in range(0, len(full_latest)):
      7     folium.Circle(
----> 8         location=[full_latest.iloc[i]['Lat'], full_latest.iloc[i]['Long']],
      9         color='crimson',
     10         tooltip =   '<li><bold>Country : '+str(full_latest.iloc[i]['Country'])+

~\Anaconda3\lib\site-packages\pandas\core\series.py in __getitem__(self, key)
   1066         key = com.apply_if_callable(key, self)
   1067         try:
-> 1068             result = self.index.get_value(self, key)
   1069 
   1070             if not is_scalar(result):

~\Anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_value(self, series, key)
   4742                     raise InvalidIndexError(key)
   4743                 else:
-> 4744                     raise e1
   4745             except Exception:  # pragma: no cover
   4746                 raise e1

~\Anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_value(self, series, key)
   4728         k = self._convert_scalar_indexer(k, kind="getitem")
   4729         try:
-> 4730             return self._engine.get_value(s, k, tz=getattr(series.dtype, "tz", None))
   4731         except KeyError as e1:
   4732             if len(self) > 0 and (self.holds_integer() or self.is_boolean()):

pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_value()

pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_value()

pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 'Lat'
python-3.x jupyter-notebook folium
1个回答
0
投票

它正在尝试引用'Lat',它不在我正在使用的数据集中。为垃圾邮件问题道歉。

© www.soinside.com 2019 - 2024. All rights reserved.