October 2017
Intermediate to advanced
532 pages
16h 10m
English
It is possible to sort one column in ascending order while simultaneously sorting another column in descending order. To accomplish this, pass in a list of booleans to the ascending parameter that corresponds to how you would like each column sorted. The following sorts title_year and content_rating in descending order and budget in ascending order. It then finds the lowest budget film for each year and content rating group:
>>> movie4 = movie[['movie_title', 'title_year', 'content_rating', 'budget']]>>> movie4_sorted = movie4.sort_values(['title_year', 'content_rating', 'budget'], ascending=[False, False, True])>>> movie4_sorted.drop_duplicates(subset=['title_year', 'content_rating']).head(10)
By default, drop_duplicates ...
Read now
Unlock full access