scatter plot error - possibly data type
ciaran.hudson at gmail.com
ciaran.hudson at gmail.com
Sun Mar 24 05:30:16 EDT 2019
Hi,
Can anyone help me with this error?
I suspect it is something to do with the data type, but don't know how to resolve.
I'm trying to plot a 2 user system dates against each other and am getting the error below.
print(type(DialogUsers.TRDAT))
<class 'pandas.core.series.Series'>
plt.scatter(DialogUsers.TRDAT, DialogUsers.ERDAT)
plt.show()
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-7-3277b90008cc> in <module>()
----> 1 plt.scatter(DialogUsers.TRDAT, DialogUsers.ERDAT)
2 plt.show()
~\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\pyplot.py in scatter(x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, verts, edgecolors, hold, data, **kwargs)
3473 vmin=vmin, vmax=vmax, alpha=alpha,
3474 linewidths=linewidths, verts=verts,
-> 3475 edgecolors=edgecolors, data=data, **kwargs)
3476 finally:
3477 ax._hold = washold
~\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\__init__.py in inner(ax, *args, **kwargs)
1865 "the Matplotlib list!)" % (label_namer, func.__name__),
1866 RuntimeWarning, stacklevel=2)
-> 1867 return func(ax, *args, **kwargs)
1868
1869 inner.__doc__ = _add_data_doc(inner.__doc__,
~\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\axes\_axes.py in scatter(self, x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, verts, edgecolors, **kwargs)
4245 edgecolors = 'face'
4246
-> 4247 self._process_unit_info(xdata=x, ydata=y, kwargs=kwargs)
4248 x = self.convert_xunits(x)
4249 y = self.convert_yunits(y)
~\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\axes\_base.py in _process_unit_info(self, xdata, ydata, kwargs)
2170 # we only need to update if there is nothing set yet.
2171 if not self.yaxis.have_units():
-> 2172 self.yaxis.update_units(ydata)
2173
2174 # process kwargs 2nd since these will override default units
~\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\axis.py in update_units(self, data)
1467 neednew = self.converter != converter
1468 self.converter = converter
-> 1469 default = self.converter.default_units(data, self)
1470 if default is not None and self.units is None:
1471 self.set_units(default)
~\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\category.py in default_units(data, axis)
113 # default_units->axis_info->convert
114 if axis.units is None:
--> 115 axis.set_units(UnitData(data))
116 else:
117 axis.units.update(data)
~\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\category.py in __init__(self, data)
180 self._counter = itertools.count(start=0)
181 if data is not None:
--> 182 self.update(data)
183
184 def update(self, data):
~\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\category.py in update(self, data)
199 for val in OrderedDict.fromkeys(data):
200 if not isinstance(val, VALID_TYPES):
--> 201 raise TypeError("{val!r} is not a string".format(val=val))
202 if val not in self._mapping:
203 self._mapping[val] = next(self._counter)
TypeError: nan is not a string
Thanks,
CiarĂ¡n
More information about the Python-list
mailing list