Append rows to a pandas DataFrame without making a new copy
PythonPandasPython Problem Overview
The pandas documentation includes a note:
>Note Unlike list.append method, which appends to the original list and returns nothing, append here does not modify df1 and returns its copy with df2 appended.
How can I append to an existing DataFrame without making a copy? Or in the terms of the note how can I modify df1 in place by appending df2 and return nothing?
Python Solutions
Solution 1 - Python
Upcoming pandas 0.13 version will allow to add rows through loc
on non existing index data.
Description is here and this new feature is called Setting With Enlargement.
Solution 2 - Python
Why not use concat?
df = pd.concat([df, pd.DataFrame(new_data)])