I am having such pandas values as follows:
df1 = pd.DataFrame({
'Lat':('-10.1','-10.2','-10.3','-10.4','-10.5','-10.6'),
'Lon':('90.000','90.050','90.100','90.150','90.200','90.250'),
'Position':('-9999.999','-9999.999','-9999.999','-9999.999','-9999.999','-9999.999')})
df1 = df1.set_index('Lat','Lon')
df2 = pd.DataFrame({
'Lat':('-10.2','-10.5'),
'Lon':('90.050','90.200'),
'Position':('50','100')
})
df2 = df2.set_index('Lat','Lon')
output=df1.combine_first(df2).reset_index()
and the answers as follows:
Lat Lon Position
0 -10.1 90.000 -9999.999
1 -10.2 90.050 -9999.999
2 -10.3 90.100 -9999.999
3 -10.4 90.150 -9999.999
4 -10.5 90.200 -9999.999
5 -10.6 90.250 -9999.999
However, I am expecting the output as follows:
Lat Lon Position
0 -10.1 90.000 -9999.999
1 -10.2 90.050 50.0
2 -10.3 90.100 -9999.999
3 -10.4 90.150 -9999.999
4 -10.5 90.200 100.0
5 -10.6 90.250 -9999.999
anynone got an ideas, please help. Thanks in advance.