Simple question, first time i am using pandas, but still could not find an answer googling.
I have this dataframe info.
info.head
artist in_train new_filename
0 Barnett Newman True 102257.jpg
1 Barnett Newman True 75232.jpg
2 kiri nichol False 32145.jpg
.
.
.
Now i want to create two new dataframes and adding rows from info to them depending on if the column in_train is True or False.
train_info = pd.DataFrame(columns=('artist', 'filename'))
test_info = pd.DataFrame(columns=('artist', 'filename'))
for index, row in info.iterrows():
if row["in_train"] == True:
train_info.append(row[["artist", "new_filename"]])
else:
test_info.append(row[["artist", "new_filename"]])
For some reason this code assigned all rows in info to test_info and nothing to train_info. How do i solve this?