pandas - subtract two columns of different Dataframe with python -


i have 2 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 substract (tp1-tp2) columns , create new dataframe colums lat1,lon1,tp1-tp2. know how can it?

import pandas 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 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -