Я пытаюсь создать пузырьковую карту в gmaps, размер пузырька основан на значениях в столбце в pandas кадре данных. Я получаю сообщение об ошибке 'TraitError: Черта' scale 'экземпляра Symbol должна быть int, но было указано значение 2335.'
Мой набор данных такой:
https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv
Я называю фрейм данных «cgr», а затем мой код выглядит так:
data_layer = gmaps.symbol_layer(
cgr[['Lat','Long']], fill_color='green', stroke_color='green', scale=cgr['5/1/20']
)
fig = gmaps.figure()
fig.add_layer(data_layer)
fig
Я не понимаю, почему gmaps не распознает числа numpy .int64 как целые числа, и я не могу преобразовать их в собственные числа python. Есть идеи?
Вот полный Traceback
TraitError Traceback (most recent call last)
<ipython-input-7-202e1cec5d37> in <module>
1 data_layer = gmaps.symbol_layer(
----> 2 cgr[['Lat','Long']], fill_color='green', stroke_color='green', scale=cgr['5/1/20']
3 )
4 fig = gmaps.figure()
5 fig.add_layer(data_layer)
~\anaconda3\lib\site-packages\gmaps\marker.py in symbol_layer(locations, hover_text, fill_color, fill_opacity, stroke_color, stroke_opacity, scale, info_box_content, display_info_box)
479 fill_opacity, stroke_color, stroke_opacity, scale,
480 info_box_content, display_info_box)
--> 481 symbols = [Symbol(**option) for option in options]
482 return Markers(markers=symbols)
483
~\anaconda3\lib\site-packages\gmaps\marker.py in <listcomp>(.0)
479 fill_opacity, stroke_color, stroke_opacity, scale,
480 info_box_content, display_info_box)
--> 481 symbols = [Symbol(**option) for option in options]
482 return Markers(markers=symbols)
483
~\anaconda3\lib\site-packages\gmaps\marker.py in __init__(self, location, **kwargs)
162 kwargs = _resolve_info_box_kwargs(**kwargs)
163 kwargs['location'] = location
--> 164 super(Symbol, self).__init__(**kwargs)
165
166
~\anaconda3\lib\site-packages\ipywidgets\widgets\widget.py in __init__(self, **kwargs)
410 """Public constructor"""
411 self._model_id = kwargs.pop('model_id', None)
--> 412 super(Widget, self).__init__(**kwargs)
413
414 Widget._call_widget_constructed(self)
~\anaconda3\lib\site-packages\traitlets\traitlets.py in __init__(self, *args, **kwargs)
995 for key, value in kwargs.items():
996 if self.has_trait(key):
--> 997 setattr(self, key, value)
998 else:
999 # passthrough args that don't set traits to super
~\anaconda3\lib\site-packages\traitlets\traitlets.py in __set__(self, obj, value)
583 raise TraitError('The "%s" trait is read-only.' % self.name)
584 else:
--> 585 self.set(obj, value)
586
587 def _validate(self, obj, value):
~\anaconda3\lib\site-packages\traitlets\traitlets.py in set(self, obj, value)
557
558 def set(self, obj, value):
--> 559 new_value = self._validate(obj, value)
560 try:
561 old_value = obj._trait_values[self.name]
~\anaconda3\lib\site-packages\traitlets\traitlets.py in _validate(self, obj, value)
589 return value
590 if hasattr(self, 'validate'):
--> 591 value = self.validate(obj, value)
592 if obj._cross_validation_lock is False:
593 value = self._cross_validate(obj, value)
~\anaconda3\lib\site-packages\traitlets\traitlets.py in validate(self, obj, value)
1868 def validate(self, obj, value):
1869 if not isinstance(value, int):
-> 1870 self.error(obj, value)
1871 return _validate_bounds(self, obj, value)
1872
~\anaconda3\lib\site-packages\traitlets\traitlets.py in error(self, obj, value)
623 e = "The '%s' trait must be %s, but a value of %r was specified." \
624 % (self.name, self.info(), repr_type(value))
--> 625 raise TraitError(e)
626
627 def get_metadata(self, key, default=None):
TraitError: The 'scale' trait of a Symbol instance must be an int, but a value of 2335 <class 'numpy.int64'> was specified.