read file with date and plot it

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

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

Dear scott,

Let's me try. I'll write back as soon as possible,

Diego

···

On 15 July 2018 at 21:56, Scott Lasley <selasley at icloud.com> wrote:

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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20180717/a67fcd41/attachment.html>