将随机播放的DF与新的输出DF合并-Pandas

时间:2019-08-24 18:17:51

标签: pandas svm

我正在尝试合并两个数据框; “混洗” DF1,用于派生(预测的输出)DF2。我能够将它们合并在一起;但是,最终结果总是“不混洗” DF1与DF2合并。因此,DF3不匹配。

df1 = shuffle(pd.read_csv("C:/Users/.."))

filename = ('C:/Users/..')
loaded_model = pickle.load(open(filename, 'rb'))

df2 = loaded_model.predict(df1)

df3= pd.merge(df1, df2, left_index=True, right_index=True)


Here's an example the problem.:

df1        df1 (Shuffled)     
 0         3
 1         2
 2         1
 3         0

df2
0
0
0
1

expected df3 = (shuffled df1) + df2:
df1   df2
3     0
2     0
1     0
0     1

however, im getting:
df1   df2
0     0
1     0
2     0
3     1  


Thanks in advance for the time and effort!

0 个答案:

没有答案