I have a similar dataframe to this one:
Names | abandoned_calls | total_calls |
---|---|---|
Kerstin | 0 | 50 |
Cathlyn | 0 | 53 |
James | 1 | 53 |
Nathaniel | 0 | 53 |
Patrick | 1 | 53 |
Lucy | 0 | 53 |
What I am trying to get is the names of the call handlers that had an abandoned call, I have tried the following code:
for content in df["abandoned_calls"] != 0:
print(df["Names"])
However, I get:
KeyError: 'Names'
I get the same error if I try:
for content in df[abandoned_calls].notnull:
print(df[Names])
The ideal response will be simply:
James
Patrick
I have also tried:
if pd.notnull(df["abandoned_calls"]):
print(df["Names"])
But I get this:
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Can you please help me with this?
You can try:
df.loc[df['abandoned_calls'] != 0, 'Names']
Result:
2 James
4 Patrick
Name: Names, dtype: object