def _slow_pivot(index, columns, values):
 tree = {}
 for (i, (idx, col)) in enumerate(zip(index, columns)):
  if (col not in tree):
   tree[col] = {}
  branch = tree[col]
  branch[idx] = values[i]
 return DataFrame(tree)

def _slow_pivot ( index , columns , values ) : tree = { } for ( i , ( idx , col ) ) in enumerate ( zip ( index , columns ) ) : if ( col not in tree ) : tree [ col ] = { } branch = tree [ col ] branch [ idx ] = values [ i ] return DataFrame ( tree )
produce pivot table based on 3 columns of this dataframe .