Interpolate and match missing values between two dataframes of different dimensions

Viewed 85

I'm new to pandas and python in general.

Currently I'm trying to interpolate and make the coordinates of two different dataframes match. The data comes from two different GEOTIFF files from the same source, one being temperature and the other being radiation. The file was converted to pandas with georasters.

The radiation dataframe has more points and data, I want to upscale the temperature dataframe and have the same coordinates as the prior.

Radiation Dataframe:

row col value x y
0 197 2427 5.755 -83.9325 17.5075
1 197 2428 5.755 -83.93 17.5075
2 197 2429 5.755 -83.9275 17.5075
3 197 2430 5.755 -83.925 17.5075
4 197 2431 5.755 -83.9225 17.5075

1850011 rows × 5 columns

Temperature Dataframe:

row col value x y
0 59 725 26.8 -83.9583 17.5083
1 59 726 26.8 -83.95 17.5083
2 59 727 26.8 -83.9417 17.5083
3 59 728 26.8 -83.9333 17.5083
4 59 729 26.8 -83.925 17.5083

167791 rows × 5 columns

Source of data "Gis data - LTAym_AvgDailyTotals (GeoTIFF)"

Temperature Map Temperature Map

Radiation (GHI) Map Radiation (GHI) Map

1 Answers

In order to be able to change the information of a column, you have to use iloc. I said I gave the fourth column from the left and index 3, which is the same as column x, then I gave it your values, then I printed the result.

import pandas as pd


Radiation = {'row':["197","197","197","197","197"],
         'col':["2427","2428","2429","2430","2431"],
         'value':['5.755','5.755','5.755','5.755','5.755'],
         'x':['-83.9325','-83.93','-83.9275','-83.925','-83.9225'],
         'y':['17.5075','17.5075','17.5075','17.5075','17.5075']
}

Temperature = { 'row':["59","59","59","59","59"],
                'col':["725","726","727","728","729"],
                'value':["26.8","26.8","26.8","26.8","26.8"],
                'x':["-83.9583","-83.95","-83.9417","-83.9333","-83.925"],
                'y':["17.5083","17.5083","17.5083","17.5083","17.5083"]
}

df1 = pd.DataFrame(Radiation)
df2 = pd.DataFrame(Temperature)
df1.iloc[4:,3]='1850011'
df2.iloc[4:,3]='167791'
Comparison = df1.compare(df2, keep_shape=True, keep_equal=True)
print(df1)
print(df2)
Related