I have an excel file with data like this:
employee id department
Jane Smith 12345 HR
Joe Smith 54321 IT
Lee Smith 52341 Admin
I create a dataframe like so:
df=pd.read_excel(filename)
I am trying to create a new dataframe of just the people in one department.
admin_folk = df[df['department'].str.contains('Admin').any()]
What I get is "KeyError: True"
Every post I see on filtering out dataframes by value use the above construct. I know that the construct returns a Boolean value, but I thought creating a new df carries all of the values for that row.
What am I doing wrong? Thanks