[Matplotlib-users] read file with date and plot it

Scott Lasley selasley at icloud.com
Sun Jul 15 15:56:39 EDT 2018


Are you using the names parameter in read_csv to set the header names?  This works for me

headers = ['date','dato1','dato2','dato3']
df = pd.read_csv('./'+folder+'/'+fname, header=None, names=headers)
df.plot(x='date',y='dato2',)

> On Jul 15, 2018, at 11:30, diedro <diego.avesani at gmail.com> wrote:
> 
> Dear all,
> 
> I have created with fortran the following file:
> 
> /
> 2013:01:02-01,-999.0000, 1.0000000E+00,1.0000000E+00
> 2013:01:02-02,-999.0000, 2.0000000E+00,0.0000000E+00
> 2013:01:02-03,-999.0000, 3.0000000E+00,2.0000000E+00
> 2013:01:02-04,-999.0000, 4.0000000E+00,0.0000000E+00
> 2013:01:02-05,-999.0000, 5.0000000E+00,3.0000000E+00/
> ....
> 
> I would like to read it and to plot data according to date
> 
> so far this is what I do:
> 
> /folder = 'meteo_stations'
> fname = 'stations_pp.txt'
> headers = ['date','dato1','dato2','dato3']
> df = pd.read_csv('./'+folder+'/'+fname,)
> 
> df.plot(x='date',y='dato2',)/
> 
> unfortunately, I get an error?
> 
> what shall I do?
> 
> Thanks for any kind of helps,
> 
> Best regards 
> 
> 
> 
> 
> 
> 
> 
> 
> --
> Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users at python.org
> https://mail.python.org/mailman/listinfo/matplotlib-users



More information about the Matplotlib-users mailing list