How can I get a data frame in another dataframe? Consider dataframe A.:
BCD 2 3 4 6 7 8 and dataframe B:
a 1 5 I want to include in A to B:
abcd 1 2 3 4 5 6 7 8 < / Div>
2 methods:
in [1]: df1 = DataFrame (RANDIN (0, 10, size = (12)). Reshape (4,3), column = list ('BCD')) [2]: df1 out [2]: BCD 0 595 1 8 4 0 2 8 4 5 3 In 492 [3]: df2 = DataFrame (RANDIN (0, 10, size = (4)). Reshape (4,1), column = list ('A')) [4]: df2 out [4]: A 0 4 1 9 2 2 3 0 Discussion (a new frame [6]: pd.concat ([df2, df1], axis = 1) out [6]: ABC 5 5 5 5 5 984 2 2 8 4 Insert a series in the existing frame
in [8]: df1.insert (0, 'a') , Df2 ['a']) [9]: df1 out [9]: abcd 0 5 5 5 5 9 8 4 2 2 8 4 5 3 4 9 2
No comments:
Post a Comment