Similar problem to this (How do I sum values in a column that match a given condition using pandas?) but in my case (https://i.stack.imgur.com/kEx1c.jpg) I have the date format in YYYY-MM-DD where I want to summarize all values in column 4 for every year. (The task is to create a function 'Rain_year' which when given an input year gives you the total rain that year)
Code:
def rain_year(a):
df.loc['a-01-01':'a-12-31']
df.loc[df['Dygn'] ==a, 'Nederbörd(mm)'].sum()
return row["Nederbörd(mm)"].sum()
rain_year("1995")
print(rain_year("1995"))
But this doesn't give me anything (neither a value or an error message).