'concatenate dataframe awith different order of column
I have two dataframes : df1:
Cluster OsId BrowserId PageId VolumePred ConversionPred
0 11 11 {789615, 955761, 1149586, 955764, 955767, 1187... 147.0 71.0
0 11 12 {1184903, 955761, 1149586, 1158132, 955764, 10... 73.0 38.0
0 11 15 {1184903, 1109643, 955761, 955764, 1074581, 95... 72.0 40.0
and df2
Cluster OsId PageId BrowserId VolumePred ConversionPred
0 11 789615 {16, 17, 11} 163.0 80.0
0 11 835198 {16} 37.0 21.0
0 11 858236 {16} 4.0 3.0
And I need to concatenate them to get this result:
Cluster OsId BrowserId PageId VolumePred ConversionPred
0 11 11 {789615, 955761, 1149586, 955764, 955767, 1187... 147.0 71.0
0 11 12 {1184903, 955761, 1149586, 1158132, 955764, 10... 73.0 38.0
0 11 15 {1184903, 1109643, 955761, 955764, 1074581, 95... 72.0 40.0
0 11 {16, 17, 11} 789615 163.0 80.0
0 11 {16} 835198 37.0 21.0
0 11 {16} 858236 4.0 3.0
I try with simply this line of code :
result = pd.concat(df1,df2)
But I got this error :
TypeError: first argument must be an iterable of pandas objects, you passed an object of type "DataFrame"
An idea please to help me to fix it
print(df1)
> Cluster OsId BrowserId \ 0 0 11 11 1 0
> 11 12 2 0 11 15
>
> PageId VolumePred \ 0 {789615, 955761, 1149586, 955764, 955767, 1187... 147.0 1
> {1184903, 955761, 1149586, 1158132, 955764, 10... 73.0 2
> {1184903, 1109643, 955761, 955764, 1074581, 95... 72.0
>
> ConversionPred 0 71.0 1 38.0 2
> 40.0
Thanks you!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
