I have a pandas dataframe that has been defined as empty and then I would like to add some rows to it after doing some calculations.
I have tried to do the following:
test = pd.DataFrame(columns=['Name', 'Age', 'Gender'])
if #some statement:
test.append(['James', '95', 'M'])
If I try to print and then append to test shows
print(test)
test.append(['a', 'a', 'a', 'a', 'a', 'a'])
print(test)
>>>
Empty DataFrame
Columns: [Name, Age, Gender]
Index: []
Empty DataFrame
Columns: [Name, Age, Gender]
Index: []
So clearly the line is not being added to the dataframe.
I want the output to be
Name | Age | Gender
James | 95 | M