2016-06-30 19 views

Antwort

0

Diese funktionieren sollte.

X.iloc[:, 4:12] = Y 

iloc und loc ermöglichen es uns, sowohl Scheibe aus und weisen auf Scheiben eines Datenrahmens

#   assign Y 
#    | 
#    /-\ 
X.iloc[:, 4:12] = Y 
# ^^
#  | | 
# slices | 
# all rows | 
#   slices columns 
#   5 through 12 
#   which constitute 
#   the 8 columns we want 
#   replace with the 8 
#   columns of Y 
+0

Warum? Warum funktioniert es? Könnten Sie bitte etwas Kontext zu Ihrer Antwort hinzufügen? – ppperry

+0

@ppperry faire Kritik. Ich werde jetzt einen Kontext hinzufügen. – piRSquared

0

Sie können nur concat sie:

pd.concat(x.ix[:,:3], y, axis=1) 

Beispiel:

In [257]: 
x = pd.DataFrame(columns=list('abcde')) 
y = pd.DataFrame(columns=list('1234')) 
pd.concat([x.ix[:,:2], y], axis=1) 

Out[257]: 
Empty DataFrame 
Columns: [a, b, 1, 2, 3, 4] 
Index: [] 
Verwandte Themen