I have a dataframe:
| ID |
|---|
| 239200202 |
| 14700993 |
| 1153709258720067584 |
And have a output whether the id is a bot or not in an array form [1,1,0] How can I combine it into one dataframe like:
| ID | Bot |
|---|---|
| 239200202 | bot |
| 14700993 | bot |
| 1153709258720067584 | Not bot |
I tried this code, but it didn't work:
test = pd.read_csv('./user_data/user_lookup/dataset/test_dataframe.csv', index_col=1)
df = pd.DataFrame(columns=['UserID','Bot/Not'])
for index,row in test.iterrows():
if test[index] == 1:
df.loc[index,['UserID']] = test['User ID']
df.loc[index,['Bot/Not']] = 'Bot'
if test[index] == 0:
df.loc[index, ['UserID']] = test['User ID']
df.loc[index, ['Bot/Not']] = 'Not-Bot'
print(df)
It would be great if someone can help me out. Thank you
test_dataframe.csvcontains ID only?arr =[1,1,0]arr = ['Bot' if x==1 else 'Not-Bot' for x in arr]