Databases and Redis · Decision guide
pandas removed DataFrame.append, and df.concat does not exist either
Short answer
AttributeError: 'DataFrame' object has no attribute 'append' comes from pandas 2.0 or newer, which removed DataFrame.append and Series.append. concat is a module function, so df.concat fails too. Write pd.concat([df, other], ignore_index=True), wrap a dict row in pd.DataFrame([row]) first, and build loop rows in a list.
AttributeError: 'DataFrame' object has no attribute 'append' is expected on pandas 2.0 or newer. The 2.0.0 release notes list DataFrame.append and Series.append among the removed deprecations and point to concat; both had printed a FutureWarning since 1.4. Nothing is wrong with your data. The method no longer exists, and the replacement is a module function, so writing df.concat(...) fails too.
How you rewrite the call depends on what the old code appended: another frame, a single dict, rows built in a loop, or a library you do not control.
Find your case
- If you appended one DataFrame or Series to anotherUse pd.concat with a list.
- If you appended a dict as a new rowTurn the dict into a one-row frame first.
- If append sits inside a loopCollect rows in a list and build the frame once.
- If the call is inside a third-party packageUpgrade the package or pin pandas below 2.0 in an isolated environment.
Appending another frame
pd.concat takes one sequence of objects as its first argument, so put both frames in a list. Keep ignore_index=True when the old call had it, so the result gets a fresh 0 to n-1 index. Options after the first argument are keyword-only.
The direct replacement
# old
df = df.append(other, ignore_index=True)
# new
df = pd.concat([df, other], ignore_index=True)Appending a dict as a row
The old method accepted a dict with ignore_index=True. concat accepts only Series and DataFrame objects, and refuses anything else with a TypeError. Wrap the dict in a list to make a one-row frame.
Dict to one-row DataFrame
row = {"name": "Ada", "score": 91}
df = pd.concat([df, pd.DataFrame([row])], ignore_index=True)Rows built in a loop
Appending inside a loop copies the entire frame on every pass, so it was always slow and gets slower as the frame grows. The pandas maintainers' advice in the deprecation discussion is to collect records first. Build a plain list in the loop and create the frame once at the end.
One DataFrame, built after the loop
rows = []
for item in source:
rows.append({"name": item.name, "score": item.score})
df = pd.DataFrame(rows)A library that still calls append
Run pip show pandas and read the Required-by line to see which packages depend on it. If a library calls append internally, the fix belongs in that library: upgrade it to a release that supports pandas 2. When none exists, run that job in its own virtual environment with pandas below 2.0, and leave your main environment current.
An isolated environment for the old library
python -m venv .venv-legacy
.venv-legacy/bin/pip install "pandas<2"After the rewrite
If concat now runs but columns come out as object dtype or fill with NaN, the frames have different columns or an empty piece. That is a different behaviour: compare df.columns of both inputs, and drop empty frames before concatenating.
- Search the project for
.append(on frames and Series, since one call is rarely alone. - Run the code with warnings as errors on pandas 1.5 first if you still have it, to catch each use.
In short
- append was removed in pandas 2.0; concat is a function on pandas, not a method.
- List of frames in, ignore_index=True for a fresh index.
- Collect loop rows in a list and build the frame once.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.