Elliott Roper <nos...@yrl.co.uk> ezt írta (időpont: 2019. aug. 14., Sze
15:56):

> On 14 Aug 2019, Elliott Roper wrote
> (in article<0001hw.23044901039e772c70000ca97...@news.giganews.com>):
>
> > On 14 Aug 2019, amirrezaheidary...@gmail.com wrote
> > (in article<23d45668-fa47-4640-832a-5a5c64600...@googlegroups.com>):
> >
> > > On Tuesday, August 13, 2019 at 11:47:28 PM UTC+2,
> amirrezah...@gmail.com
> > > wrote:
>
> Oh Damn! Here is an attempt to stop the code running into a single line..
> > >
> > > > I have a .csv file, in first column I have date and hour, and in the
> second
> > > > column I have energy use data. How can I make a bar chart with Date
> and
> > > > time as the x axis and the energy use as the Y axis?
> > > >
> > > > Thanks
> > >
> > > Thank you for your guidance. I am already using matplotlib but I do
> not know
> > > how to import a column of date and time and to use it properly as the x
> > > axis.
> > > can you tell me the code?
> > >
> > > Thanks
>
> >
> > If you don't mind using a steam hammer to crack a nut, it is amazing
> what you
> > can do with pandas using just the "10 minute guide" chapter in the
> (shudder)
> > 10,000 page manual. The chief benefit is how thoroughly it protects you
> from
> > Numpy and Matplotlib.
> > I solved a similar problem (tracking home blood pressure with
> exponentially
> > weighted means) up and running in half a day from a completely cold
> start.
> > The graphing bit is a delight. However, if you want to do something that
> the
> > 10 minute guide does not cover, you can lose a man-month without really
> > trying. Pandas is a beautiful monster!
> >
> > Here's the relevant bit
> >
> > import numpy as np
> >
> > import pandas as pd
> >
> > import matplotlib.pyplot as plt
> >
> >
> > #preparing the csv from a text file elided as irrelevant
> >
> > #except that the .csv headings have to be Date Systolic Diastolic for
> this to
> > work as designed
> >
> > # Plot the intermediate file with pandas after adding exponentially
> weighted
> > means
> >
> > df = pd.read_csv('Blood pressure.csv')
> >
> > df['Date'] = pd.to_datetime(df['Date'])
> >
> > df['Syst EWM'] = df['Systolic'].ewm(span=200).mean()
> >
> > df['Diast EWM'] = df['Diastolic'].ewm(span=200).mean()
> >
> > plt.ioff()
> >
> > df.plot(x='Date')
> >
> > print(df.tail(60)) #a debug line I left in to watch the EWMs sink to more
> > healthy levels
> >
> > plt.ylabel('mm Hg')
> >
> > plt.suptitle("Home BP record")
> >
> > plt.show()
> >
> > That should give you a start
>
> --
> To de-mung my e-mail address:- fsnospam$elliott$$ PGP Fingerprint: 1A96
> 3CF7
> 637F 896B C810 E199 7E5C A9E4 8E59 E248
>
> --
> https://mail.python.org/mailman/listinfo/python-list




Hi,

Pygal is a very good and easy to use charting library

BR,
George


>
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to