Jul-27-2019, 08:01 PM
check what reorderRows is in your first code example
just by inserting a print(reorderRows) before that line
and index=['1', '2', '3', '4', '5', '6'] is not the same as index=[('1', '2', '3', '4', '5', '6')]
which i assume you get printed out using print(reorderRows) as suggested because the error you get
KeyError: "[('1', '2', '3', '4', '5', '6')] not in index"
says exactly this
just by inserting a print(reorderRows) before that line
df_cm = df_cm.reindex(index=[reorderRows])Looking at your second code example
cm=cm.reindex(index=['1', '2', '3', '4', '5', '6'])reorderRows must be the same as '1', '2', '3', '4', '5', '6' but if you assign it like this
reorderRows = '1', '2', '3', '4', '5', '6'reorderRows is of type tuple ('1', '2', '3', '4', '5', '6')
and index=['1', '2', '3', '4', '5', '6'] is not the same as index=[('1', '2', '3', '4', '5', '6')]
which i assume you get printed out using print(reorderRows) as suggested because the error you get
KeyError: "[('1', '2', '3', '4', '5', '6')] not in index"
says exactly this