我正在尝试绘制一个非常简单的csv列表。通过阅读类似的问题,我明确设置了定界符,尽管在这种情况下不必这样做。错误消息说纬度数据不在列中,但它们在吗?不是吗很抱歉那个菜鸟问题。
sample.csv内容:
In [663]: times = pd.to_datetime(df['date'])
In [662]: df.groupby([times.dt.year, times.dt.day]).mean()
Out[662]:
O_3 NO_2 SO_2 PM10 PM25 CO
Date
1 14.963333 65.831666 17.638333 37.748333 11.087606 0.39
30 52.250000 58.250000 4.000000 4.750000 4.000000 0.30
我的代码
lat,lon
41.3183890,2.1034560
41.3184440,2.1034180
41.3184960,2.1033760
41.3185610,2.1033510
41.3186100,2.1033080
41.3186690,2.1032710
41.3187210,2.1032330
41.3187800,2.1031950
41.3188360,2.1031580
41.3188970,2.1031240
错误:
KeyError:“ [Float64Index([41.380008000000004,41.379993,41.379975,\ n 41.379939,41.379921,41.379883,\ n 41.379852,41.379815,41.379778,\ n 41.379739,\ n ... \ n ... \ n 41.380067,41.380041999999996,41。 ,\ n 41.37999,41.379965999999996,41.379982,\ n 41.380025,41.380067,41.380108,\ n 41.380142],\ n dtype ='float64',length = 4709)]位于[列]“中
答案 0 :(得分:1)
用以下代码替换最后一行代码:
df_list.plot('lat', 'lon')