I have a two dataframes as follows:
df1:
A B C D E 0 8 6 4 9 7 1 2 6 3 8 5 2 0 7 6 5 8 df2:
M N O P Q R S T 0 1 2 3 1 4 5 6 2 7 8 9 3 8 6 5 4 5 4 3 I have taken out a slice of data from df1 as follows:
>data_1 = df1.loc[0:1] >data_1 A B C D E 0 8 6 4 9 7 1 2 6 3 8 5 Now I need to insert this data_1 into df2 at specific location of Index(0,P) (row,column). Is there any way to do it? I do not want to disturb the other columns in df2.
I can extract individual values of each cell and do it but since I have to do it for a large dataset, its not possible to do it cell-wise.
Cellwise method:
>var1 = df1.iat[0,1] >var2 = df1.iat[0,0] >df2.at[0, 'P'] = var1 >df2.at[0, 'Q'] = var2