Draw the mean on a graph with matplotlib

0

I am working with the following table

In the graphic I have drawn the line of values (blue) of the table and, in red color, I have set the average value of the column Visits made with a loop:

media = visitsPerDay['Visits'].mean()

mediaArr = []
for i in range(len(visitsPerDay)):
    mediaArr.append(media)

plt.plot( visitsPerDay['Day'], visitsPerDay['Visits'], 'b-', visitsPerDay['Day'], mediaArr, 'r-')

Is it possible, just with the value of the average, to draw it as it appears in the graph? Or do I have to create an array necessarily?

    
asked by gmarsi 12.08.2018 в 20:45
source

0 answers