Import modules

#import modules
import pandas as pd

Create a dummy dataframe

#create a dataframe
data = {'name': ['Cristiano Ronaldo', 'Neymar','Kylian Mbappé','Erling Haaland','Léo Messi','Karim Benzema'],
'age': [36, 29,22,20,33,33],
'height_cm': [187, 175,178,194,170, 187],
'club': ['Juventus FC', 'Paris Saint Germain','Paris Saint Germain','Borussia Dortmund','FC Barcelona', 'Real Madrid'],
'country': ['Portugal', 'Brazil','France','Norway','Argentina','France']}
df = pd.DataFrame(data)
df
 
 nameageheight_cmclubcountry
0Cristiano Ronaldo36187Juventus FCPortugal
1Neymar29175Paris Saint GermainBrazil
2Kylian Mbappé22178Paris Saint GermainFrance
3Erling Haaland20194Borussia DortmundNorway
4Léo Messi33170FC BarcelonaArgentina
5Karim Benzema33187Real MadridFrance

 

Filters on rows containing word "Paris Saint Germain"


#Filter on players playing in Paris Saint Germain
df_filtered = df[df['club'].str.contains('Paris Saint Germain')]
df_filtered
 
 nameageheight_cmclubcountry
1Neymar29175Paris Saint GermainBrazil
2Kylian Mbappé22178Paris Saint GermainFrance
Looking for a job?
Join 5,000+ subscribers
No commitment. Cancel anytime.