Good morning,
Basically I have 2 pandas dataframes from CSVs:
Dataframe 1: each row is a group where the row index is a geographical area code, and the columns are the top 5 most similar areas. e.g:
0 1 2 3 4 5
Rank
00C 00C 03H 02D 05H 02E 04E
00D 00D 02P 02X 01X 03R 06M
Dataframe 2: This is a larger dataframe with hospital activity numbers broken down by age group, gender and the geographical areas. e.g:
MALE_0-4 MALE_5-9 FEMALE_80-84 FEMALE_85+
06M 75 59 43 48
00C 132 121 173 204
01X 84 63 124 102
03H 127 131 130 83
02P 93 89 208 151
02D 70 62 92 81
05H 96 76 52 32
00C 106 62 123 106
03R 75 59 43 48
02P 10 121 173 204
03R 84 63 124 102
03R 30 131 130 83
02E 93 89 208 151
06M 70 62 92 81
04E 96 76 52 32
00D 106 62 123 106
What I am trying to do is create smaller dataframes from Dataframe 2 - filtered by the groupings from Dataframe 1. Each geographical area code can appear in multiple lookups. I have a basic idea of for loops, but can't quite get it to work.
Dataframe Output 1:
MALE_0-4 MALE_5-9 FEMALE_80-84 FEMALE_85+
00C 132 121 173 204
03H 127 131 130 83
02D 70 62 92 81
05H 96 76 52 32
00C 106 62 123 106
02E 93 89 208 151
04E 96 76 52 32
Dataframe Output 2:
MALE_0-4 MALE_5-9 FEMALE_80-84 FEMALE_85+
06M 75 59 43 48
01X 84 63 124 102
02P 93 89 208 151
03R 75 59 43 48
02P 10 121 173 204
03R 84 63 124 102
03R 30 131 130 83
06M 70 62 92 81
00D 106 62 123 106
...
Hope this makes sense and any help would be appreciated.