Pandas equivalent rbind operation

Basically, I am browsing through a bunch of CSV files and, in the end, would like to append each dataframe into one. In fact, all I need is a function like rbind . So, I did a search and followed a guide . However, I still could not get the perfect solution.

The following is sample code. For example, the form of data1 is always 47 to 42. But the form data_out_final becomes (47, 42), (47, 84) and (47, 126) after the first three files. Ideally, it should be (141, 42). In addition, I check the data1 index, which is RangeIndex(start=0, stop=47, step=1) . Rate any suggestions!

My version of pandas 0.18.1

the code

 appended_data = [] for csv_each in csv_pool: data1 = pd.read_csv(csv_each, header=0) # do something here appended_data.append(data2) data_out_final = pd.concat(appended_data, axis=1) 

If data_out_final = pd.concat(appended_data, axis=1) , the form data_out_final becomes (141, 94)

PS

kind of it. In fact, you need to standardize the column names to pd.concat .

+6
source share
2 answers
 >>> df1 ab 0 -1.417866 -0.828749 1 0.212349 0.791048 2 -0.451170 0.628584 3 0.612671 -0.995330 4 0.078460 -0.322976 5 1.244803 1.576373 6 1.169629 -1.135926 7 -0.652443 0.506388 8 0.549604 -0.691054 9 -0.512829 -0.959398 >>> df2 ab 0 -0.652161 0.940932 1 2.495067 0.004833 2 -2.187792 1.692402 3 1.900738 0.372425 4 0.245976 1.894527 5 0.627297 0.029331 6 -0.828628 -1.600014 7 -0.991835 -0.061202 8 0.543389 0.703457 9 -0.755059 1.239968 >>> pd.concat([df1, df2]) ab 0 -1.417866 -0.828749 1 0.212349 0.791048 2 -0.451170 0.628584 3 0.612671 -0.995330 4 0.078460 -0.322976 5 1.244803 1.576373 6 1.169629 -1.135926 7 -0.652443 0.506388 8 0.549604 -0.691054 9 -0.512829 -0.959398 0 -0.652161 0.940932 1 2.495067 0.004833 2 -2.187792 1.692402 3 1.900738 0.372425 4 0.245976 1.894527 5 0.627297 0.029331 6 -0.828628 -1.600014 7 -0.991835 -0.061202 8 0.543389 0.703457 9 -0.755059 1.239968 

If I misinterpret what you need, this is what you need.

+9
source

Try: http://pandas.pydata.org/pandas-docs/stable/10min.html?highlight=concat#concat

"pandas provides various options for simply combining Series, DataFrame, and Panel objects with different types of set logic for indexes and relational algebra functionality in the case of union / join operations."

0
source

All Articles