简体   繁体   中英

wrong shape with concat and append in python

I have two datasets df1 with shape (4045, 188) and df2 with shape (10505, 188)

df1 = pd.read_csv('ptbdb_normal.csv')
df2 = pd.read_csv('ptbdb_abnormal.csv')

To concat them i use:

frames = [df1,df2]
df_con = pd.concat(frames)

or

data_appended =df1.append(df2)

However this approach returns me Dataframe with shape (14550,309)
What I need is new dataset with shape (14750,188)

Where am I making mistake?
I took it from pandas docs, and SO thread here ( merging two datasets with same index)

My problem is exactly the same as the one ilustrated here:

https://datascience.stackexchange.com/questions/10783/how-do-i-merge-two-data-frames-in-python-pandas

在此处输入图像描述

df1.columns=df2.columns.values
data_appended =df1.append(df2)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM