Pandas Dataframes

Let’s now see how to filter on multiple columns

Code:

import pandas as pd

df = pd.read_excel('europe_cities_by_sunshine.xlsx')

df[ (df['Year'] > 3000) & (df['Country'] == 'Cyprus')]

Explanation:

We can also filter on a column name, rather than just specifying for values above or below certain figures. Here, it returns data for Cyprus and above 3000 but will filter out Cyprus cities below 3000.