Reputation: 85
Quick Q:
Have a dataset: That is a measurment per day over several years. Trying to work out the average of all the same dates. i.e the average of 01/01/1995 and 01/01/1996 and 01/01/1997 etc.
Tried this:
z=df.groupby(df.index.day,df.index.month).mean()
But get:
TypeError: unhashable type: 'numpy.ndarray'
Cheers
Upvotes: 3
Views: 2595
Reputation: 1187
Hey @EdChum just adding this as an answer, as the display of the comment doesn't let me show what I meant. I agree that date format is a superior syntax! However, when I do it in reverse order I get
WindSpeed
1 1 1 9.283333
1 2 6.694444
1 3 7.861111
1 4 9.223529
...
1 31 8.964706
2 1 9.127778
2 2 8.733333
2 3 7.511111
...
Where the first index is month, and the second is day. When I do in the order you suggested, I get:
WindSpeed
1 1 9.283333
1 2 8.361111
1 3 6.670588
1 4 7.155556
1 5 8.450000
1 6 4.777778
1 7 3.666667
1 8 4.011765
1 9 5.210526
1 10 6.972222
1 11 7.647059
1 12 6.844444
...
Where the first index is day (from 1-31), and the second is month (from 1-12). We usually look at data sequentially, with January 1 followed by Jan 2. In yours, January first is followed by February first. That confused me for a bit! Mine worked better for my needs anyways. I appreciated your answer here a lot! Helped me with my problem.
Upvotes: 1