Aug-07-2020, 10:33 PM
Right, makes sense. It's just tough to make a concise example b/c the data is so lengthy.
I did some more experimenting and I've figured out what's going on. Resample() will interpolate, but not extrapolate. So if I have sales of an Item in Jan and Dec, I will get 12 values, even if there is zero sales in Feb-thru-Nov. If I have sales in Mar and Jun only, but none in Jan-Feb or Jul-Dec, I will get 4 values (Mar, Apr, May, Jun).
So, because I have sales of something in every month of the year, my solution was to unstack() the dataframe after the resample(). That forced the resampled 12 months along the top as columns with a ton of NaN's. I filled the NaN's with zeros, then stack(), and presto, 12 values for every item.
Seems a little kludgy, maybe there's a better way?
I did some more experimenting and I've figured out what's going on. Resample() will interpolate, but not extrapolate. So if I have sales of an Item in Jan and Dec, I will get 12 values, even if there is zero sales in Feb-thru-Nov. If I have sales in Mar and Jun only, but none in Jan-Feb or Jul-Dec, I will get 4 values (Mar, Apr, May, Jun).
So, because I have sales of something in every month of the year, my solution was to unstack() the dataframe after the resample(). That forced the resampled 12 months along the top as columns with a ton of NaN's. I filled the NaN's with zeros, then stack(), and presto, 12 values for every item.
Seems a little kludgy, maybe there's a better way?