def usecase01(gedcom_name): today = datetime.datetime.today() df = Project02.createIndividualsDataFrame(gedcom_name) df2 = Project02.createFamiliesDataFrame(gedcom_name) dateDict = [] for index, row in df.iterrows(): #iterates through dataframe day = row['Birthday'] dateDict.append(day) for index, row in df.iterrows(): #iterates through dataframe day = row['Dead'] dateDict.append(day) for index, row in df2.iterrows(): #iterates through dataframe dateDict.append(row['Married']) ''' for index, row in df2.iterrows(): #iterates through dataframe dateDict.append(row['Divorced']) ''' for date in dateDict: if date == 'nan': continue else: day = pd.to_datetime(date) if day > today: return "There is at least one date later than the current date" return "All dates are before today"
def siblingsAgeGap(gedcom_name): # I need to gather all the siblings of each family # check if their birthdays are more than 8 months apart # check if their birthdays are less than 2 days apart #return true if they are valid, false if they are not eight_months = 240 two_days = 2 individuals = Project02.createIndividualsDataFrame(gedcom_name) families = Project02.createFamiliesDataFrame(gedcom_name) child = [] children = copy.deepcopy(families["Children"]) print(children)
def listLivingMarried(gedcom_name): # iterate through dataframe and check if current individual is married # if not, continute to next individual # if they are, check if they are alive #if they are, add to list # if not, continue #return list living_married = [] individuals = Project02.createIndividualsDataFrame(gedcom_name) for ind, row in individuals.iterrows(): if (type(row['Spouse']) == float and pd.isna(row['Spouse'])): pass elif (individuals['Alive'][ind] == 'True'): living_married.append(individuals['Name'][ind]) # print(individuals['Name'][ind]) return living_married # # listLivingMarried("testing.ged") # '''testing''' # class Inneo_Tests_HW4(unittest.TestCase): # def test1(self): # filename = "testing.ged" # ret = ['John Smith', 'Susan Jones', 'Frank Jones', 'Emily Michaels', 'Bernard Smith', 'Theresa Kelly', 'Kevin Brown', 'Diane Brown'] # self.assertEqual(listLivingMarried(filename),ret) # if __name__ == '__main__': # unittest.main()
def us22(gedcom_file): families = Project02.createFamiliesDataFrame(gedcom_file) individuals = Project02.createIndividualsDataFrame(gedcom_file) invalid = [] for idx in range(len(families.ID)): vfy = families.ID.drop([idx]) if families.ID[idx] in vfy: invalid.append(families.ID[idx]) for idx in range(len(individuals.ID)): vfy = individuals.ID.drop([idx]) if individuals.ID[idx] in vfy: invalid.append(individuals.ID[idx]) return invalid
def user02(gedcom_file): individuals = Project02.createIndividualsDataFrame(gedcom_file) families = Project02.createFamiliesDataFrame(gedcom_file) indiv_list = pd.DataFrame(columns = [individuals.Name, individuals.Birthday]) fam_list = pd.DataFrame(columns = [families["Wife Name"], families["Husband Name"], families.Married]) ''' for i, row in indiv_list.iterrows(): for k, row in fam_list.iterrows(): if indiv_list[individuals.Name][i]== fam_list[families["Wife Name"]][k] or indiv_list[individuals.Name][i]==fam_list[families["Husband Name"]][k]: if indiv_list[individuals.Birthday][i] == fam_list[families.Married]: return True else: return False ''' print(fam_list)
def usecase07(gedcom_name): today = datetime.datetime.today() df = Project02.createIndividualsDataFrame(gedcom_name) for index, row in df.iterrows(): #iterates through dataframe birth = pd.to_datetime(row['Birthday']) if row['Dead'] == 'nan': death = today else: death = pd.to_datetime(row['Dead']) dif = death.year - birth.year if death.month < birth.month or (death.month == birth.month and death.day < birth.day): dif -= 1 if dif >= 150: return "At least one individual lived to be over 150" return "All ages are less than 150"
def test5(self): individuals = Project02.createIndividualsDataFrame('test5.ged') df = individuals[0:11] df = df.append(individuals.iloc[4]).reset_index(drop=True) res = [] self.assertEqual(us22('test5.ged'), res)
def test4(self): families = Project02.createFamiliesDataFrame('test3.ged') df = families[0:len(families)] df = df.append(families.iloc[len(families) - 1]).reset_index(drop=True) res = [] self.assertEqual(us22('test3.ged'), res)
def test2(self): families = Project02.createFamiliesDataFrame('test1.ged') df = families[0:len(families) - 2] res = [] self.assertEqual(us22('test1.ged'), res)
def test5(self): individuals = Project02.createIndividualsDataFrame('seed.ged') df = individuals[0:11] df = df.append(individuals.iloc[4]).reset_index(drop=True) res = "not unique" self.assertEqual(us23(df), res)
def test2(self): individuals = Project02.createIndividualsDataFrame('seed.ged') df = individuals[0:5] res = "unique" self.assertEqual(us23(df), res)