pd.concat warns about empty or all-NA entries, then changes dtypes in pandas 3
Your error
FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries is deprecated. In a future version, this will no longer exclude empty or all-NA columns when determining the result dtypes. To retain the old behavior, exclude the relevant entries before the concat operation.1 more line it can showFix it fast
Most common cause, 1 of 3An empty placeholder frame sits at the front of the list
Do not seed the result with an empty frame.
import pandas as pd
parts = [load(name) for name in names] # no empty starter frame
parts = [p for p in parts if not p.empty]
result = pd.concat(parts, ignore_index=True) if parts else pd.DataFrame()Short answer
The FutureWarning about DataFrame concatenation with empty or all-NA entries appears on pandas 2.1 to 2.3 when an empty frame or all-missing column is skipped while choosing result dtypes. pandas 3.0 counts them, so the warning is gone and columns can become object. Drop empty frames and cast all-NA columns to the real dtype before pd.concat.
Which cause do you have?
Before the concat line, print each piece's row count and the columns that hold no values at all. A piece with zero rows is cause 1; a non-empty piece listing columns is cause 2; Series pieces point to cause 3.
for i, part in enumerate(parts):
print(i, type(part).__name__, len(part), list(part.columns[part.isna().all()]) if hasattr(part, "columns") else "")Then find the line you see in this list and open its fix:
- 1An empty placeholder frame sits at the front of the list
One piece reports 0 rows, typically a pd.DataFrame(columns=[...]) created before a loop - 2A piece has a column that is NaN or None in every row
The piece has rows, but the printout lists one or more columns with no values, and their dtype differs from the same column elsewhere - 3Series concat includes an empty Series
The text says array concatenation with empty entries rather than DataFrame concatenation
What does the error look like?
FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries is deprecated. In a future version, this will no longer exclude empty or all-NA columns when determining the result dtypes. To retain the old behavior, exclude the relevant entries before the concat operation.FutureWarning: The behavior of array concatenation with empty entries is deprecated. In a future version, this will no longer exclude empty items when determining the result dtype. To retain the old behavior, exclude the empty entries before the concat operation.
Cause 1 of 3
An empty placeholder frame sits at the front of the list
You seeOne piece reports 0 rows, typically a pd.DataFrame(columns=[...]) created before a loop
Check
A frame made from column names alone has object columns and no rows. When it meets float data, pandas 2.x skips that empty piece while choosing the dtype and warns, because the answer is about to change; the 3.0.0 notes say concat no longer ignores empty objects, so the column comes out object.
print(parts[0].shape, parts[0].dtypes.to_dict())Fix
Do not seed the result with an empty frame. Gather real pieces in a list and concatenate once; if empty results can come back from a query or file, filter them out on the way in.
import pandas as pd
parts = [load(name) for name in names] # no empty starter frame
parts = [p for p in parts if not p.empty]
result = pd.concat(parts, ignore_index=True) if parts else pd.DataFrame()Verify
The warning no longer prints on 2.x, and on 3.x the numeric columns keep float64 or int64 instead of object.
print(len(parts), result.dtypes.to_dict())Confirmed by pandas.pydata.org
Cause 2 of 3
A piece has a column that is NaN or None in every row
You seeThe piece has rows, but the printout lists one or more columns with no values, and their dtype differs from the same column elsewhere
Check
The pandas issue behind this change shows a float column made only of NaN meeting a datetime64 column. The old path skipped the all-missing column and returned datetime64, while a Series concat of the same data already gave object. pandas 3 applies the dtype-only rule to frames as well.
print({c: part[c].dtype for c in part.columns[part.isna().all()]})Fix
Give the empty column the dtype the other pieces use, so dtypes agree before the concat. If the column carries nothing you need, dropping it from that piece also works, since an outer concat still fills it with missing values.
# match the dtype used by the other pieces
part = part.astype({"created_at": other["created_at"].dtype})
# or drop columns that are entirely missing in this piece
part = part.dropna(axis=1, how="all")
result = pd.concat([part, other], ignore_index=True)Verify
result.dtypes shows the same dtype as the other piece for that column on both pandas 2.3 and 3.x, with no FutureWarning.
print(result.dtypes)Confirmed by github.com
Cause 3 of 3
Series concat includes an empty Series
You seeThe text says array concatenation with empty entries rather than DataFrame concatenation
Check
The second message comes from the array-level code that Series concat uses. In pandas 2.3 an empty object Series next to an int64 Series is skipped and the result stays int64, with this warning; that exclusion is the behaviour pandas 3 retired.
print([(len(s), s.dtype) for s in series_list])Fix
Remove zero-length Series before concatenating, or create the empty one with the dtype the others have.
series_list = [s for s in series_list if len(s)]
combined = pd.concat(series_list)
# or, when an empty one must stay:
placeholder = pd.Series([], dtype="int64")Verify
combined.dtype is the expected numeric dtype and no warning prints.
print(combined.dtype)Confirmed by raw.githubusercontent.com
How do I stop it coming back?
- Start every accumulation as a Python list of frames, never as an empty DataFrame, and call pd.concat once.
- Call astype right after you create or reindex a frame, so a column that is still empty already has its final dtype.
- Before moving a project from pandas 2.3 to 3.x, fix every concat FutureWarning first, because 3.x changes the result silently.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. 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.
Which stack is behind this page?
Projects of mine on the same stack: stegnor.com, Menulo, ShopGo.