我有2个表,我可以合并2个表而不按ID合并吗?因为这两个表的ID不一致。这两个表的行数相同。如果有人能帮上忙,我将不胜感激。


发布于 2020-06-07 00:37:33
我不确定它是否回答了您的问题,但请尝试以下代码:
import pandas as pd
table1 = pd.DataFrame(table1) #Table with the first three columns
table2= pd.Series(table2) #Table with Price Prediction
table1["Price Prediction"] = table2发布于 2020-06-07 17:06:01
我相信有更好的方法来实现。不过,我是这样解决问题的。
df_out = Table1.reset_index()
Prediction_df = pd.DataFrame(predictions)
Prediction_df = Prediction_df.rename(columns={'XXX': 'Prediction'})
Prediction_df['prediction'] = Prediction_df.reset_index()['Prediction']
df_out1 = pd.merge(df_out,Prediction_df[['prediction']],how = 'left',left_index = True, right_index = True)https://stackoverflow.com/questions/62233464
复制相似问题