I am trying to iterate through the rows of a CSV file where I saved a list of my followers, with the data associated to the subscribing event and a flag that specifies if I already unsubscribed from the specific follower.
Here is an example of the file:
List of follower with data of subscription and unsubscribe flag
Right now I am trying to build a loop in that way:
I try to calculate a new variable time_d
that gives me the number of days since the subscription.
Then I will do an if
statement in which I ask:
- if the subscription occurred more than 7 days ago AND my
flag_unsubscribe = 'NO'
then try etc.
df = pd.read_csv("follower.csv",parse_dates=[1])
for row in df.itertuples():
time_d = pd.Timestamp("today") - row[2]
print(time_d)
converted_time_d = pd.DataFrame([time_d]).apply(np.float32)
print(converted_time_d," - ",row[3])
#if all((all(converted_time_d)>=7) and all(str(row[3]))!='1.0'):
if all((all(converted_time_d)<=7) and str(row[3])=="NO"):
try:
Right now, I am receiving this error:
Traceback (most recent call last):
File "C:\Users\XXX\OneDrive\Desktop\XXX\unfollow_by_profile.py", line 26, in <module>
if all((all(converted_time_d)<=7) and str(row[3])=="NO"):
TypeError: 'bool' object is not iterable
Can someone help me? I tried to look on a similar post, but I did not find anything that could fix the problem.