Empty dataframe when filtering

Tags: , , ,



I have a dataframe that looks like this:

enter image description here

Now I’d like to filter like this:

df1.loc[df1['PZAE'] == 'HAE']

However, I am getting an empty dataframe. enter image description here

What am I doing wrong here?

Answer

Try df1.loc[df1['PZAE']=="'HAE'"]

Details :

the column 'PZAE' contains str starting and finishing by ' that’s why you have to include them in the condition



Source: stackoverflow