Python Forum
Help with two lines in a function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with two lines in a function
#2
check what reorderRows is in your first code example
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
Reply


Messages In This Thread
Help with two lines in a function - by amjass12 - Jul-27-2019, 05:32 PM
RE: Help with two lines in a function - by ThomasL - Jul-27-2019, 08:01 PM
RE: Help with two lines in a function - by amjass12 - Jul-28-2019, 08:30 AM
RE: Help with two lines in a function - by ThomasL - Jul-28-2019, 08:50 AM
RE: Help with two lines in a function - by amjass12 - Jul-28-2019, 09:33 AM
RE: Help with two lines in a function - by ThomasL - Jul-28-2019, 09:47 AM
RE: Help with two lines in a function - by amjass12 - Jul-28-2019, 12:41 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Importing a function from another file runs the old lines also dedesssse 6 2,702 Jul-06-2021, 07:04 PM
Last Post: deanhystad
  Iterate 2 large text files across lines and replace lines in second file medatib531 13 6,197 Aug-10-2020, 11:01 PM
Last Post: medatib531

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020