Python Forum
Inconsistent sorting with the .sort_values() function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Inconsistent sorting with the .sort_values() function
#4
Thanks again. I looked into what you said and you are correct. I changed the column to a numeric dtype using apply(pd.to_numeric) and was able to sort it correctly.

The only issue now is that the column name has been removed (assuming because it is no longer a string?) so I can't figure out how to combine the two columns (Country/Region, Inflation Yearly Basis) back into a dataframe so I can plot it. Any ideas?

I've attached the code.

Attached Files

.py   Sorting Issue.py (Size: 1.71 KB / Downloads: 1)
Reply


Messages In This Thread
RE: Inconsistent sorting with the .sort_values() function - by devansing - Jun-28-2022, 05:02 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  ValueError: Found input variables with inconsistent numbers of samples: [5, 6] bongielondy 6 27,005 Jun-28-2021, 05:23 AM
Last Post: ricslato
  ValueError: Found input variables with inconsistent numbers of sample robert2joe 0 4,394 Mar-25-2020, 11:10 AM
Last Post: robert2joe
  ValueError: Found input variables with inconsistent numbers of samples: [0, 3] ayaz786amd 2 9,717 Nov-27-2018, 07:12 AM
Last Post: ayaz786amd

Forum Jump:

User Panel Messages

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