python读取csv数据画直⽅图_⽤python为csv⽂件中的列绘制
直⽅图
我试图为给定csv⽂件中的特定列绘制直⽅图和散点图。我是编程新⼿,我从⼀个朋友那⾥得到了这段代码,它显然是有效的,但不知怎么的,我得到了这个错误。代码是:import csv
import numpy as np
import matplotlib.pyplot as plt
f = open('Data for question 13.csv')
data = ader(f)
Area = []; MajorAxisLength = []; MinorAxisLength = []; Perimeter = []
MinIntensity = []; MeanIntensity = []; MaxIntensity = []
header = [Area, MajorAxisLength, MinorAxisLength,Perimeter,MinIntensity,MeanIntensity,MaxIntensity]python怎么读csv数据
for row in data:
i = 1
for name in header:
name.append(row[i])
i = i + 1
plt.figure()
plt.hist(Area, bins=50) # error follows after this
错误:Traceback (most recent call last):
File "", line 1, in
plt.hist(Area, bins=50, alpha=0.5)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/pyplot.py", line 2827, in hist
stacked=stacked, **kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/axes.py", line 8312, in hist
xmin = min(xmin, xi.min())
File "/Library/Python/2.7/site-packages/numpy-1.9.0-py2./numpy/core/_methods.py", line 29, in _amin
return umr_minimum(a, axis, None, out, keepdims)
TypeError: cannot perform reduce with flexible type
我⽆法摆脱这个错误。
答案应该很简单,但由于我是新来的,我不知道如何处理它。
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论