Python With Excel and Text Strings
Pandas Dataframes
Let’s see how to filter a dataframe
Code:
import pandas as pd
df = pd.read_excel('europe_cities_by_sunshine.xlsx')
df['Year'] > 3000
Explanation:
Now, in the df[‘Year’] > 3000 (which was the inside portion of the previous lesson’s filtered dataframe), we can see it returns a series of True/False, and this True/False series is the used to determined which rows to return — for ex, it will not return the last row since it has False s the label in it. This is to explain how filtering in a dataframe works and can explain how the syntax makes sense.