pandas concat错误:无法连接非NDFrame对象 [英] pandas concat error: cannot concatenate a non-NDFrame object

查看:219
本文介绍了pandas concat错误:无法连接非NDFrame对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个数据框,我只是编写一个简单的pd.concat来垂直附加数据:

I have two data frames and I am just writing a simple pd.concat to append the data vertically:

    SRC_OF_PAYMENT_80_00_CY= 
    pd.concat(['src_of_payment_cy','src_of_payment_df'],axis=0, ignore_index=True)

都是数据框类型。所以我不明白错误:
TypeError:无法连接非NDFrame对象

Both are dataframes types. So I don't understand the error: TypeError: cannot concatenate a non-NDFrame object

Here is the out for df.info() for both:
<class 'pandas.core.frame.DataFrame'>
Int64Index: 10 entries, 0 to 9
Data columns (total 3 columns):
Type_of_cost    10 non-null object
Total_NHE       10 non-null float64
year            10 non-null int64
dtypes: float64(1), int64(1), object(1)
memory usage: 320.0+ bytes
src_of_payment_cy

<class 'pandas.core.frame.DataFrame'>
Int64Index: 18 entries, 9 to 26
Data columns (total 3 columns):
Type_of_cost    18 non-null object
Total_NHE       18 non-null int64
year            18 non-null int64
dtypes: int64(2), object(1)
memory usage: 576.0+ bytes
src_of_payment_df 


推荐答案

删除数据框名称周围的撇号-

Remove the apostrophes around the dataframe names like -

SRC_OF_PAYMENT_80_00_CY= 
    pd.concat([src_of_payment_cy,src_of_payment_df],axis=0, ignore_index=True)

这篇关于pandas concat错误:无法连接非NDFrame对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆