I'm trying to create an empty pandas DataFrame with the columns ['ImageName','faces','ImageWidth', 'ImageHeight'] to which I'm trying to append a row. Let's take the following row as an example: ['selfie_10.png',3,200,300].
So far, I've come up with the following code snippet. But either it doesn't work or it throws an error.
import pandas as pd
columns = ['ImageName','faces','ImageWidth', 'ImageHeight']
df = pd.DataFrame(columns=columns)
for i in range(0,10):
row = ['selfie_10.png',3,200,300]
df.append(row,ignore_index=True)
print(df)
The output is unfortunately an empty array.
In [72]:runfile('/Users/add_row.py', wdir='/Users/Desktop/faces')
Empty DataFrame
Columns: [ImageName, faces, ImageWidth, ImageHeight]
Index: []
Can anybody help me?
df.loc[i] = rowin the for loop instead of appending.