df.append() is not appending to the DataFrame df.append() is not appending to the DataFrame pandas pandas

df.append() is not appending to the DataFrame


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         D0  value aa  value bb  value cc  value dd1  value aa  value bb  value cc  value dd


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.