Python Forum
Sorting a DataFrame - Best Practice?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sorting a DataFrame - Best Practice?
#1
Hello,

I am using Jupyer and SQL magic to create a dataframe from my query:
df = query_from_magic.DataFrame()
I then wanted to look at a sub-set of that data. In this specific example, I want to probe into a given date and then sort the results based on the integer stored in the 'count' column:
df_check = df.loc[df.date == '2020-01-28'] 
df_check.sort_values(by='count', inplace=True, ascending=True)
df_check
I am getting the warning about SettingWithCopyWarning.

Is there a better approach to what I am trying to do? It doesn't make sense to me that I should create a copy of my new, filtered data frame to simply sort it..
Reply
#2
Here' a good resource for you to understand SettingWithCopyWarning:
https://www.dataquest.io/blog/settingwithcopywarning/
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  frustrating practice taubee 9 4,143 Nov-22-2020, 04:23 AM
Last Post: taubee
  Pre-release practice help! Wilson1218 3 3,327 Nov-05-2017, 04:21 PM
Last Post: buran
  Practice Question Excersizes A3G 5 6,215 Oct-16-2016, 12:38 PM
Last Post: A3G

Forum Jump:

User Panel Messages

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