df.append() is not appending to the DataFrame

The statement data.append(sub_data) does not work on its own.

But the statement data=data.append(sub_data) will work

Assigning it back solved the issue for me. Good tip not available elsewhere.


DataFrame.append is not an in-place operation. From the docs,

DataFrame.append(other, ignore_index=False, verify_integrity=False, sort=None)

Append rows of other to the end of this frame, returning a new object. Columns not in this frame are added as new columns.

You need to assign the result back.

df8 = df8.append([s] * 2, ignore_index=True)
df8
          A         B         C         D
0  value aa  value bb  value cc  value dd
1  value aa  value bb  value cc  value dd