Python no longer uses panel. I am not skilled enough to think of an alternative and hoping someone knows of a work around. I have been using the code below for some time but after an update it no longer works. I would prefer to update the code then revert back to older unsupported versions. the issue i am having is panel is deactivated. can you see a work around to this problem? for what i am trying to accomplish is find the beta of a stock. i have taken the code from the following link
Efficient Python Pandas Stock Beta Calculation on Many Dataframes
def roll(df, w):
# stack df.values w-times shifted once at each stack
roll_array = np.dstack([df.values[i:i+w, :] for i in range(len(df.index) - w + 1)]).T
# roll_array is now a 3-D array and can be read into
# a pandas panel object
panel = pd.Panel(roll_array,
items=df.index[w-1:],
major_axis=df.columns,
minor_axis=pd.Index(range(w), name='roll'))
# convert to dataframe and pivot + groupby
# is now ready for any action normally performed
# on a groupby object
return panel.to_frame().unstack().T.groupby(level=0)
rdf = roll(df, 156)