Stuck defining a function in my Portfolio Project :(


I’m doing my first portfolio project for my Data Scientist degree and I can’t seem to find the key to write a function…

What I want to achieve with the function is to select women and men with similar characteristics (in this case age, bmi, whether they are smokers or not and number of children) so that I can then compare how much it costs them to pay for health insurance. I want to do it this way so that factors such as smoking or bmi do not have a big influence on the amount they have to pay.

class PatientsInfo:
    def __init__(self, patients_ages, patients_sexes, patients_bmis, patients_num_children, patients_smoker_status,
                 patients_regions, patients_charges, all_data):
        self.patients_ages = patients_ages
        self.patients_sexes = patients_sexes
        self.patients_bmis = patients_bmis
        self.patients_num_children = patients_num_children
        self.patients_smoker_status = patients_smoker_status
        self.patients_regions = patients_regions
        self.patients_charges = patients_charges
        self.all_data = all_data

    def dif_men_women(self):
        total_men_charge = 0
        total_women_charge = 0
        elegible_pacients = []
        for pacient in self.all_data:
            if pacient == (sexes == "male") and pacient == (num_children == 2) and pacient == (smoker_status == "no"):

patients_info = PatientsInfo(ages, sexes, bmi, num_children, smoker_status, regions, insurance_charges, all_data)


Double check the spelling of “patient” & “patients” in your function inside your class.

1 Like