Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- index = cars.index
- index.has_duplicates # return True or False
- index.value_counts() # can see the most frequent value
- #########################################
- titanic.loc[1] # only by first index
- titanic.loc[(slice(None), slice('female')), :] # only by second index
- titanic.loc[(slice(1), slice('female')), :]
- titanic.loc[(1,'female'), 'age')]
- titanic.loc[([1,2],'female'), 'age')]
- titanic.swaplevel().sort_index() # swap the indexes and sort
- titanic.reset_index()
- #########################################
- cars.set_index(["model_year", "origin"]).sort_index(ascending = [True, True])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement