|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 没有土豆的洋芋 于 2017-4-23 23:02 编辑
python2.7的
数据大概有上百个 我用小的数据就对了 哪错了 啊 求大神指教 不胜感激
import csv
from matplotlib import pyplot as plt
filename='F://London Accidents with GEO info apart.csv'
with open(filename) as f:
reader=csv.reader(f)
header_row=next(reader)
print(header_row)
for index,column_header in enumerate(header_row):
print(index,column_header)
with open(filename) as f:
reader=csv.reader(f)
header_row=next(reader)
Severitys=[]
for row in reader:
Severitys.append(row[3])
print(Severitys)
Severitys=[]
for row in reader:
Severity=int(row[3])
Severitys.append(Severity)
print(Severitys)
fig=plt.figure(dpi=128,figsize=(10,6))
plt.plot(Severitys,c='red')
plt.title("London Accidents with GEO info apart",fontsize=24)
plt.xlabel('',fontsize=20)
plt.ylabel("Severitys",fontsize=20)
plt.tick_params(axis='both',which='major',labelsize=16)
plt.show()
中
Severitys=[]
for row in reader:
Severity=int(row[3])
Severitys.append(Severity)
print(Severitys)
程序如上 将字符串转换成数字 并打印出来
为什么我运行结果 是: [] 里面并没有数字啊
求大神指教
|
|