前提・実現したいこと
機械学習目的でpythonを始めたばかりの初心者の質問です。
素人すぎる質問で恐縮です。
OS:mac mojave
JupyterでCSVファイルを視覚化。
https://news.mynavi.jp/article/zeropython-3/
発生しているエラーメッセージ
ImportError Traceback (most recent call last) <ipython-input-53-e966873d93bd> in <module> 2 import pandas as pd 3 df = pd.read_csv("population.csv", encoding="SHIFT_JIS") ----> 4 df.plot.bar(y=['平成28年']) ~/.pyenv/versions/3.6.5/lib/python3.6/site-packages/pandas/plotting/_core.py in bar(self, x, y, **kwds) 3088 >>> ax = df.plot.bar(x='lifespan', rot=0) 3089 """ -> 3090 return self(kind='bar', x=x, y=y, **kwds) 3091 3092 def barh(self, x=None, y=None, **kwds): ~/.pyenv/versions/3.6.5/lib/python3.6/site-packages/pandas/plotting/_core.py in __call__(self, x, y, kind, ax, subplots, sharex, sharey, layout, figsize, use_index, title, grid, legend, style, logx, logy, loglog, xticks, yticks, xlim, ylim, rot, fontsize, colormap, table, yerr, xerr, secondary_y, sort_columns, **kwds) 2939 fontsize=fontsize, colormap=colormap, table=table, 2940 yerr=yerr, xerr=xerr, secondary_y=secondary_y, -> 2941 sort_columns=sort_columns, **kwds) 2942 __call__.__doc__ = plot_frame.__doc__ 2943 ~/.pyenv/versions/3.6.5/lib/python3.6/site-packages/pandas/plotting/_core.py in plot_frame(data, x, y, kind, ax, subplots, sharex, sharey, layout, figsize, use_index, title, grid, legend, style, logx, logy, loglog, xticks, yticks, xlim, ylim, rot, fontsize, colormap, table, yerr, xerr, secondary_y, sort_columns, **kwds) 1975 yerr=yerr, xerr=xerr, 1976 secondary_y=secondary_y, sort_columns=sort_columns, -> 1977 **kwds) 1978 1979 ~/.pyenv/versions/3.6.5/lib/python3.6/site-packages/pandas/plotting/_core.py in _plot(data, x, y, subplots, ax, kind, **kwds) 1800 data.columns = label_name 1801 -> 1802 plot_obj = klass(data, subplots=subplots, ax=ax, kind=kind, **kwds) 1803 1804 plot_obj.generate() ~/.pyenv/versions/3.6.5/lib/python3.6/site-packages/pandas/plotting/_core.py in __init__(self, data, **kwargs) 1180 1181 self.log = kwargs.pop('log', False) -> 1182 MPLPlot.__init__(self, data, **kwargs) 1183 1184 if self.stacked or self.subplots: ~/.pyenv/versions/3.6.5/lib/python3.6/site-packages/pandas/plotting/_core.py in __init__(self, data, kind, by, subplots, sharex, sharey, use_index, figsize, grid, legend, rot, ax, fig, title, xlim, ylim, xticks, yticks, sort_columns, fontsize, secondary_y, colormap, table, layout, **kwds) 105 table=False, layout=None, **kwds): 106 --> 107 _raise_if_no_mpl() 108 _converter._WARN = False 109 self.data = data ~/.pyenv/versions/3.6.5/lib/python3.6/site-packages/pandas/plotting/_core.py in _raise_if_no_mpl() 55 # TODO(mpl_converter): remove once converter is explicit 56 if not _HAS_MPL: ---> 57 raise ImportError("matplotlib is required for plotting.") 58 59 ImportError: matplotlib is required for plotting.
該当のソースコード
Python
1 2 %matplotlib inline 3 import pandas as pd 4 df = pd.read_csv("population.csv", encoding="SHIFT_JIS") 5 df.plot.bar(y=['平成28年']) 6
サンプルCSV
CSV
1 2都道府県,平成22年,平成27年,平成28年 3東京都,13159 ,13515 ,13624 4神奈川県,9048 ,9126 ,9145 5大阪府,8865 ,8839 ,8833 6愛知県,7411 ,7483 ,7507 7埼玉県,7195 ,7267 ,7289 8
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。