Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 3
Message 1 of 4

filtering and plotting data

Solved! Go to Solution.

import pandas as pd
from numpy import genfromtxt
import matplotlib.pyplot as plt
import io

path="uptimerobot-RP&SPublicAvailability-logs.csv"
df=pd.read_csv(path)

df.drop(['Reason', 'Monitor URL','Date-Time','Duration'], axis = 1, inplace = True)
data=df['Duration_min'][df['Event']=='Down'].sum()

data2=genfromtxt(BytesIO(data),delimiter=',',dtype=None)
plt.xlabel('Down')
plt.ylabel('Duration in min')
plt.show(data2)

plt.savefig('my_figure.png')

3 Replies
Copilot Lvl 3
Message 2 of 4

Re: filtering and plotting data

I am having problems to get the graph displayed, any suggestion?Thank you all!

Highlighted
Solution
Commander Lvl 2
Message 3 of 4

Re: filtering and plotting data

The matplotlib samples all show a call to plot() before show().

 

So perhaps you need to:

plt.ylabel('Duration in min')
plt.plot()
plt.show(data2)

?

 

Please follow-up to let us know how you made out. For good karma, mark a reply as the answer if it helped!

Copilot Lvl 3
Message 4 of 4

Re: filtering and plotting data

Thank you! Yes, this is the solution. 

df=pd.read_csv("document.csv")
data=df['Duration_min'][df['Event']=='Down']
plt.xlabel('number of Downs')
plt.ylabel('Duration in min')
plt.plot(data)