def _make_df_square(table):
 if (not isinstance(table, pd.DataFrame)):
  return table
 if (table.shape[0] != table.shape[1]):
  ix = list((set(table.index) | set(table.columns)))
  table = table.reindex(ix, axis=0)
  table = table.reindex(ix, axis=1)
 table = table.reindex(table.columns)
 return table

def _make_df_square ( table ) : if ( not isinstance ( table , pd . DataFrame ) ) : return table if ( table . shape [ 0 ] != table . shape [ 1 ] ) : ix = list ( ( set ( table . index ) | set ( table . columns ) ) ) table = table . reindex ( ix , axis = 0 ) table = table . reindex ( ix , axis = 1 ) table = table . reindex ( table . columns ) return table
reindex a pandas dataframe so that it becomes square .