I have this dataframe:
studyarea_pcdn
POSTCODE Number of meters
0 NE4 9UP 41
1 NE4 9UN 32
2 NE4 9UL 29
3 NE4 9EN 27
4 NE4 9DY 25
5 NE4 9ED 22
6 NE4 9EL 18
7 NE4 9EE 13
8 NE4 9UJ 11
9 NE4 9DX 6
10 NE4 9EA 4
Then I have this other:
sa_gas_pcd_2018[['POSTCODE', 'Number of meters']]
POSTCODE Number of meters
628318 NE4 9UP 41
628315 NE4 9UJ 36
628317 NE4 9UN 32
628199 NE4 9DY 29
628201 NE4 9EE 28
628316 NE4 9UL 28
628205 NE4 9EN 26
628200 NE4 9ED 20
628198 NE4 9DX 19
628204 NE4 9EL 17
I would like to select from sa_gas_pcd_2018 those rows that have a matching postcode to studyarea_pcdn ['POSTCODE'] and have number of meters +- 2 when compared to studyarea_pcdn['Number of meters']
The correct answer should be:
POSTCODE Number of meters
628318 NE4 9UP 41
628317 NE4 9UN 32
628316 NE4 9UL 28
628205 NE4 9EN 26
628200 NE4 9ED 20
628204 NE4 9EL 17
I have tried quite a few things but I am really stuck as I am not sure how to frame this issue. Happy if anyone has any pointers.