2015-02-18 14 views
18

supponiamo di avere due dataframes:panda equivalenti di cbind di R (vettori concatenare/pila verticale)

import pandas 
.... 
.... 
test1 = pandas.DataFrame([1,2,3,4,5]) 
.... 
.... 
test2 = pandas.DataFrame([4,2,1,3,7]) 
.... 

Ho provato test1.append(test2) ma è l'equivalente di R rbind.

Come è possibile combinare le due come due colonne di un dataframe simile alla funzione cbind in R?

risposta

32
test3 = pd.concat([test1, test2], axis=1) 
test3.columns = ['a','b'] 
+1

Ho fatto questo e aggiungo le righe, come se fosse un join - che non è quello che voglio. – Sophologist

+0

Asse = 2 è quello che vuoi? – cphlewis

+1

Solo per completezza: http://stackoverflow.com/questions/33088010/pandas-column-bind-cbind-two-data-frames –