temperatures_ind = temperatures.set_index("city") # Index temperatures by city
print(temperatures_ind) # Look at temperatures_ind
print(temperatures_ind.reset_index()) # Reset the index, keeping its contents
print(temperatures_ind.reset_index(drop=True)) # Reset the index, dropping its contents
cities = ["Moscow", "Saint Petersburg"] # Make a list of cities to subset
print(temperatures[temperatures["city"].isin(cities)]) # Subset temperatures using square brackets
print(temperatures_ind.loc[cities]) # Subset temperatures_ind using .loc[]
temperatures_ind = temperatures.set_index(["country", "city"]) # Index temperatures by country & city
rows_to_keep = [("Brazil", "Rio De Janeiro"), ("Pakistan", "Lahore")] # List of tuples: Brazil, Rio De Janeiro & Pakistan, Lahore
print(temperatures_ind.loc[rows_to_keep]) # Subset for rows to keep
print(temperatures_ind.sort_index()) # Sort temperatures_ind by index values
print(temperatures_ind.sort_index(level=["city"])) # Sort temperatures_ind by index values at the city level
print(temperatures_ind.sort_index(level=["country","city"], ascending=[True,False])) # Sort temperatures_ind by country then descending city