Tôi có một khung dữ liệu đơn giản trong gấu trúc có hai cột số. Tôi muốn tạo một biểu đồ ra khỏi các cột bằng cách sử dụng matplotlib thông qua gấu trúc. Ví dụ bên dưới không hoạt động:cách vẽ đồ thị biểu đồ từ các khung dữ liệu trong gấu trúc
In [6]: pandas.__version__
Out[6]: '0.14.1'
In [7]: df
Out[7]:
a b
0 1 20
1 2 40
2 3 30
3 4 30
4 4 3
5 3 5
In [8]: df.plot(kind="hist")
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-8-4f53176a4683> in <module>()
----> 1 df.plot(kind="hist")
/software/lib/python2.7/site-packages/pandas/tools/plotting.pyc in plot_frame(frame, x, y, subplots, sharex, sharey, use_index, figsize, grid, legend, rot, ax, style, title, xlim, ylim, logx, logy, xticks, yticks, kind, sort_columns, fontsize, secondary_y, **kwds)
2095 klass = _plot_klass[kind]
2096 else:
-> 2097 raise ValueError('Invalid chart type given %s' % kind)
2098
2099 if kind in _dataframe_kinds:
ValueError: Invalid chart type given hist
tại sao loại biểu đồ không hợp lệ? các cột có dạng số và có thể được tạo thành biểu đồ.
Thử cài đặt lại Pandas. Điều đó làm việc cho tôi. – samthebrand