I'm using a very simple piece of code and initializing a pandas dataframe with a single row and then adding other rows from a list named itemsets_dct and then appending them to the dataframe, using the following code:
finalResults = pd.DataFrame({'Concept1': itemsets_dct[0][0][0], 'Concept2': itemsets_dct[0][0][1], 'Concept3': itemsets_dct[0][0][2], 'Concept4': itemsets_dct[0][0][3], 'Count': itemsets_dct[0][1]}, index=[0])
for i in range(1,len(itemsets_dct)):
tempResult = pd.DataFrame({'Concept1': itemsets_dct[i][0][0], 'Concept2': itemsets_dct[i][0][1], 'Concept3': itemsets_dct[i][0][2], 'Concept4': itemsets_dct[i][0][3], 'Count': itemsets_dct[i][1]}, index=[i])
finalResults.append(tempResult)
when I run this code, it executes without any errors, but the finalResults variable only has 1 row, the row that I initialized.
Why is the code not appending rows to the dataframe?
appendis not an inplace operation, so you need to reassign. i.e.finalResults = finalResults.append(tempResult).