#NEWLINE# def _make_df_square( table ) : #NEWLINE# #INDENT# '\n    Reindex a pandas DataFrame so that it becomes square, meaning that\n    the row and column indices contain the same values, in the same\n    order.  The row and column index are extended to achieve this.\n    ' #NEWLINE# if ( not isinstance ( table , pd . DataFrame ) ) : #NEWLINE# #INDENT# return table #NEWLINE# #UNINDENT# if ( table . shape [ 0 ] != table . shape [ 1 ] ) : #NEWLINE# #INDENT# ix = list ( ( set ( table . index ) | set ( table . columns ) ) ) #NEWLINE# table = table . reindex ( ix , axis = 0 ) #NEWLINE# table = table . reindex ( ix , axis = 1 ) #NEWLINE# #UNINDENT# table = table . reindex ( table . columns ) #NEWLINE# return table