Using NGFS data I have concluded mean pregnant is nearly the same inside family (having more than 1 child) and when comapring diffirent families (first vs other on pairwise globally). Example code for inside family calculation below (38.62 vs 38.52 weeks).
import itertools import nsfg preg_map = nsfg.MakePregMap(live) preg = nsfg.ReadFemPreg() # get only caseid with more than 1 baby for caseid, index in preg_map.copy().items(): if len(index) < 2: preg_map.pop(caseid) # Calculte mean pregnant length for first baby first_index_list = list(j[0] for j in list(preg_map.values())) mean_first = sum(preg.iloc[i].prglngth for i in first_index_list ) / len(first_index_list) # Calculte mean pregnant length for second and next baby other_index_list = list(j[1:] for j in list(preg_map.values())) other_index_list_flattened = list(itertools.chain(*other_index_list)) mean_others = sum(preg.iloc[i].prglngth for i in other_index_list_flattened ) / len(other_index_list_flattened) print("Mean pregnant lenght for first baby [weeks]: {0}".format(round(mean_first,2))) print("Mean pregnant lenght for second and next baby [weeks]: {0}".format(round(mean_others,2))) #Mean pregnant lenght for first baby [weeks]: 38.62 #Mean pregnant lenght for second and next baby [weeks]: 38.52