I have a file named jwd.csv which has data of the weather every day from 2009 to 2019( data has temperature 24 hours a day , and of all days). The question is to plot the average minimum temperature for all years from 2009-2019.so I am taking an average of every year.
from matplotlib import pyplot as plt
import pandas as pd
import re
dataf = pd.read_csv("jwd.csv")
data = pd.read_csv("jwd.csv", index_col ="date")
r=[]
y=[]
w=[]
#taking lower and upper range
c = input('lower range')
l=int(c)
lis= []
m = int(input('upper range'))
o = m+1
p = str(l)
num1=dataf.date
num = list(num1)
num2=dataf.mintempC
nums = list(num2)
while o>l :
pattern = str(l)
for i in num:
year = re.search(pattern,i)
e=int()
if year != None:
inde = num.index(i)
x=int(inde)+2
y.append(i)
s=int(pattern)
k=nums[inde]
r.append(k)
q=data.iloc[[inde]]
for p in range(0, len(r)):
r[p] = int(r[p])
g=sum(r)
v=len(r)
t=g/v
lis.append(t)
w.append(c)
r.clear()
l+=1
for p in range(0, len(r)):
r[p] = int(r[p])
plt.plot(w,lis, color= 'green')
plt.title("mintempc")
plt.ylabel("mintempc")
plt.xlabel("date")
plt.show()
plt.show()
The graph is not made properly and the graph only shows a straight vertical line.