Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pandas error when appending dataframes: invalid dtype determination in get_concat_dtype

I have two dataframes with the same dtypes:

>>> df1.dtypes
Out[3]: 

GUID             object
RID               int64
SID               int64
Threshold       float64
Average         float64
dtype: object

>>> df2.dtypes
Out[4]: 

GUID           object
RID             int64
SID             int64
Threshold     float64
Average       float64
dtype: object

When running df1.append(df2) or pd.concat([df1,df2])

I'm getting the following error:

in get_empty_dtype_and_na
    raise AssertionError("invalid dtype determination in get_concat_dtype")

Any idea what am I missing?

like image 311
Mugen Avatar asked Apr 02 '26 07:04

Mugen


1 Answers

Problem was MultiIndex

Using droplevel fixed the issue.

Very confusing error message.

df1.columns.droplevel(1)
df1.append(df2)
like image 141
Mugen Avatar answered Apr 11 '26 08:04

Mugen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!