def pir(df):
    dv = df.values
iv = df.index.values
cv = df.columns.values
rc, cc = df.shape
return pd.DataFrame(dict(value=dv.flatten(), id=np.tile(cv, rc)), np.repeat
    (iv, cc))
Converting to long panel data format with pandas