Я пытаюсь получить телефонные номера на основе выбора пользователя
#the dict that contains the data I need
x={"contact":
{
"facility_message": "testing testing testing",
"facilitydigits":101,
"name": "",
"urn": "tel:+1234567891011",
"uuid": "60409852-a2089-43d5-bd4c-4b89a6191793",
"selection_anc_pnc":"C"
}
}
#extracting data from the dict
facility_number=str(x['contact']['facilitydigits'])
group=(x['contact']['selection_anc_pnc']).upper()
facility_message=(x['contact']['facility_message'])
#checking user selection
if group =='A':
group="MIMBA"
elif group =='B':
group='MAMA'
elif group=='C':
group='MAMA' and "MIMBA"
Мой df выглядит так
phone group County PNC/ANC Facility Name Optedout Facility Code
25470000040 MIMBA Orange PNC Centre FALSE 101
25470000030 MAMA Orange PNC Centre FALSE 101
25470000010 MIMBA Orange PNC Centre FALSE 101
25470000020 MAMA Orange PNC Centre FALSE 101
25470000050 MAMA Orange PNC Main Centre FALSE 112
извлечение телефонных номеров из моего df
phone_numbers =merged_df.loc[(merged_df['Facility Code'] ==facility_number) & (merged_df['group'] == group) & (merged_df['Opted out'] == optout)]['phone']
print(phone_numbers)
что происходит в настоящее время из-за оператора if
[25470000010,25470000040]
желаемый вывод
[25470000040,25470000030,25470000010,25470000020]