subtract two columns of different Dataframe with python
Question: I have two DataFrames, df1:

    
    
         Lat1         Lon1     tp1
    0   34.475000  349.835000   1
    1   34.476920  349.862065   0.5
    2   34.478833  349.889131   0
    3   34.480739  349.916199   3
    4   34.482639  349.943268   0
    5   34.484532  349.970338   0
    

and df2:

    
    
          Lat2         Lon2    tp2
    0   34.475000  349.835000   2
    1   34.476920  349.862065   1
    2   34.478833  349.889131   0
    3   34.480739  349.916199   6
    4   34.482639  349.943268   0
    5   34.484532  349.970338   0
    

I want to substract (tp1-tp2) columns and create a new dataframe whose colums
are Lat1,lon1,tp1-tp2. anyone know how can I do it?


Answer: 
    import pandas as pd
    
    df3 = df1[['Lat1', 'Lon1']]
    df3['tp1-tp2'] = df1.tp1 - df2.tp2
    
    
    Out[97]: 
          Lat1      Lon1  tp1-tp2
    0  34.4750  349.8350     -1.0
    1  34.4769  349.8621     -0.5
    2  34.4788  349.8891      0.0
    3  34.4807  349.9162     -3.0
    4  34.4826  349.9433      0.0
    5  34.4845  349.9703      0.0
    

