前提・実現したいこと
pythonでデータ分析を行っています
matplotlibを使って、データの可視化を行いたとい思っていますが、
下のエラーメッセージがでてきました。
エラーメッセージの意味を分解して教えて頂きたいです。
発生している問題・エラーメッセージ
TypeError Traceback (most recent call last)
/tmp/ipykernel_36/997856417.py in <module>
1 x=data["日付"]
2 y=data["金額"]
----> 3 plt.plot(x,y,"o")
4 plt.show()
/opt/conda/lib/python3.7/site-packages/matplotlib/pyplot.py in plot(scalex, scaley, data, *args, **kwargs)
3019 return gca().plot(
3020 *args, scalex=scalex, scaley=scaley,
-> 3021 **({"data": data} if data is not None else {}), **kwargs)
3022
3023
/opt/conda/lib/python3.7/site-packages/matplotlib/axes/_axes.py in plot(self, scalex, scaley, data, *args, **kwargs)
1603 """
1604 kwargs = cbook.normalize_kwargs(kwargs, mlines.Line2D)
-> 1605 lines = [*self._get_lines(*args, data=data, **kwargs)]
1606 for line in lines:
1607 self.add_line(line)
/opt/conda/lib/python3.7/site-packages/matplotlib/axes/_base.py in call(self, data, *args, **kwargs)
313 this += args[0],
314 args = args[1:]
--> 315 yield from self._plot_args(this, kwargs)
316
317 def get_next_color(self):
/opt/conda/lib/python3.7/site-packages/matplotlib/axes/_base.py in _plot_args(self, tup, kwargs, return_kwargs)
496 self.axes.xaxis.update_units(x)
497 if self.axes.yaxis is not None:
--> 498 self.axes.yaxis.update_units(y)
499
500 if x.shape[0] != y.shape[0]:
/opt/conda/lib/python3.7/site-packages/matplotlib/axis.py in update_units(self, data)
1446 neednew = self.converter != converter
1447 self.converter = converter
-> 1448 default = self.converter.default_units(data, self)
1449 if default is not None and self.units is None:
1450 self.set_units(default)
/opt/conda/lib/python3.7/site-packages/matplotlib/category.py in default_units(data, axis)
107 # the conversion call stack is default_units -> axis_info -> convert
108 if axis.units is None:
--> 109 axis.set_units(UnitData(data))
110 else:
111 axis.units.update(data)
/opt/conda/lib/python3.7/site-packages/matplotlib/category.py in init(self, data)
183 self._counter = itertools.count()
184 if data is not None:
--> 185 self.update(data)
186
187 @staticmethod
/opt/conda/lib/python3.7/site-packages/matplotlib/category.py in update(self, data)
218 for val in OrderedDict.fromkeys(data):
219 # OrderedDict just iterates over unique values in data.
--> 220 _api.check_isinstance((str, bytes), value=val)
221 if convertible:
222 # this will only be called so long as convertible is True.
/opt/conda/lib/python3.7/site-packages/matplotlib/_api/init.py in check_isinstance(_types, **kwargs)
95 ", ".join(names[:-1]) + " or " + names[-1]
96 if len(names) > 1 else names[0],
---> 97 type_name(type(v))))
98
99
TypeError: 'value' must be an instance of str or bytes, not a float
該当のソースコード
python
x=data["日付"]
y=data["金額"]
plt.plot(x,y,"o")
plt.show()
回答1件
あなたの回答
tips
プレビュー