read file with date and plot it

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

read file with date and plot it

diedro
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
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: read file with date and plot it

matplotlib - users mailing list
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 <[hidden email]> 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
> [hidden email]
> https://mail.python.org/mailman/listinfo/matplotlib-users

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: read file with date and plot it

diedro
Dear scott,

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

Diego


On 15 July 2018 at 21:56, Scott Lasley <[hidden email]> 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 <[hidden email]> 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
> [hidden email]
> https://mail.python.org/mailman/listinfo/matplotlib-users



_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users