python plot csv keyerror

时间:2018-01-08 20:22:08

标签: python csv plot keyerror

    import pandas as pd
    from datetime import datetime
    import csv
    import matplotlib.pyplot as plt
    import matplotlib.dates as mdates
    headers = ['Sensor Value','Date','Time']
    df = pd.read_csv('C:\\Users\\aaa\\Desktop\\python_test\\roaddata.CSV',names=headers)
    print (df)




    x = df['Time']
    y = df['Distance']

    # plot
    plt.plot(x,y)

    plt.show()




----------------CSV is below--------------------

Date, Time, Elapsed time, Distance, Speed (km/h), Latitude, Longitude, Accuracy (meters), Altitude, Altitude accuracy
8.01.2018, 18:15:52 GMT+3, 00:00, 0.00, 17.2, 40.973487, 29.232253, 5.000000, 130.674511, 4.000000 
8.01.2018, 18:15:55 GMT+3, 00:02, 0.02, 20.6, 40.973647, 29.232361, 5.000000, 130.701052, 4.000000 
8.01.2018, 18:15:58 GMT+3, 00:05, 0.04, 20.6, 40.973834, 29.232479, 8.333333, 130.091269, 4.000000 
8.01.2018, 18:16:01 GMT+3, 00:08, 0.06, 20.6, 40.973989, 29.232586, 5.000000, 129.352620, 4.000000 

------------- ----------------误差

我有错误" keyerror",即使信息在csv中,我也无法弄清楚为什么,它会在距离,时间等方面给出错误

请帮助我,谢谢...

KeyError:'距离'

0 个答案:

没有答案