'Trying to for-loop over and find specific strings in a dataframe using if-statement
counter = 0
for i in range(len(df)):
print[df.loc[i, "Emotional State"]]
if i in ["Happy"]:
counter+=1
print(['counter: ', counter]
The print results is: b'Happy' and the data in the dataset is "Happy" no spaces etc. For some reason i is never equal to Happy, which is not possible as it will be the first iteration. Any ideas why the output is not matching the if statement or data in the frame? The counter is always 0
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
