I have a dataframe that is the child of a merge operation on two dataframes. I end up with a multi-index that looks like (timestamp,id) and for the sake of argument, a single column X.
I would like to do several statistics on X by year, and by ID. Instead of posting all the crazy errors that I am getting trying to blindly solve this problem, I ask instead "how would you do this?"
There is one row of X per id, per period (daily). I want to aggregate to an annual period.
I think you can use
groupby
withresample
and aggregate e.g.sum
, but need pandas 0.18.1:Another solution is use
get_level_values
withgroupby
: