Programme for Influence of Relations with Parents on an Ideal Romantic Relationship
import pandas
import numpydata = pandas.read_csv(‘addhealth_pds.csv’, low_memory=False)print (len(data)) #number of observations (rows)
print (len(data.columns)) # number of variables (columns)#setting variables you will be working with to numeric
data[‘H1ID1A’] = pandas.to_numeric(data[‘H1ID1A’])
data[‘H1WP2’] = pandas.to_numeric(data[‘H1WP2’])#counts and percentages (i.e. frequency distributions) for each variable
print (‘counts for H1ID1A — going out together in a group, yes=1, no=2, refused=6, do not know=8, not applicable=9’)
ct1= data.groupby(‘H1ID1A’).size()
print (ct1)print (‘percentages for H1ID1A — going out together in a group, yes=1, no=2, refused=6, do not know=8, not applicable=9’)
pt1 = data.groupby(‘H1ID1A’).size() * 100 / len(data)
print (pt1)print (‘counts for H1WP2 - allowed to make their own decisions about the people they hang around with by their parents, yes=1, no=2, refused=6, no MOM or DAD=7, do not know=8, not applicable=9’)
ct2= data.groupby(‘H1WP2’).size()
print (ct2)print (‘percentages for H1WP2 - allowed to make their own decisions about the people they hang around with by their parents, yes=1, no=2, refused=6, no MOM or DAD=7, do not know=8, not applicable=9’)
pt2 = data.groupby(‘H1WP2’).size() * 100 / len(data)
print (pt2)print (‘counts for H1WP17D - talked about someone they are dating, or a party they went to with their MOTHER/ADOPTIVE MOTHER/STEPMOTHER/FOSTER MOTHER/etc, no=0, yes=1, refused=6, no MOM or DAD=7, do not know=8’)
ct2= data.groupby(‘H1WP17D’).size()
print (ct2)print (‘percentages for H1WP17D - talked about someone they are dating, or a party they went to with their MOTHER/ADOPTIVE MOTHER/STEPMOTHER/FOSTER MOTHER/etc, no=0, yes=1, refused=6, no MOM or DAD=7, do not know=8’)
pt2 = data.groupby(‘H1WP17D’).size() * 100 / len(data)
print (pt2)#upper-case all DataFrame column names — place afer code for loading data above
data.columns = map(str.upper, data.columns)# bug fix for display formats to avoid run time errors — put after code for loading data above
pandas.set_option(‘display.float_format’, lambda x:’%f’%x)
6504
2829
counts for H1ID1A — going out together in a group, yes=1, no=2, refused=6, do not know=8, not applicable=9
H1ID1A
1 5396
2 984
6 63
8 56
9 5
dtype: int64
percentages for H1ID1A — going out together in a group, yes=1, no=2, refused=6, do not know=8, not applicable=9
H1ID1A
1 82.964330
2 15.129151
6 0.968635
8 0.861009
9 0.076876
dtype: float64
counts for H1WP2 allowed to make their own decisions about the people they hang around with by their parents, no=0, yes=1, refused=6, no MOM or DAD=7, do not know=8, not applicable=9
H1WP2
0 942
1 5420
6 3
7 131
8 7
9 1
dtype: int64
percentages for H1WP2 allowed to make their own decisions about the people they hang around with by their parents, no=0, yes=1, refused=6, no MOM or DAD=7, do not know=8, not applicable=9
H1WP2
0 14.483395
1 83.333333
6 0.046125
7 2.014145
8 0.107626
9 0.015375
dtype: float64
counts for H1WP17D talked about someone they are dating, or a party they went to with their MOTHER/ADOPTIVE MOTHER/STEPMOTHER/FOSTER MOTHER/etc., no=0, yes=1, refused=6, no MOM or DAD=7, do not know=8
H1WP17D
0 3228
1 2895
6 6
7 370
8 5
dtype: int64
percentages for H1WP17D talked about someone they are dating, or a party they went to with their MOTHER/ADOPTIVE MOTHER/STEPMOTHER/FOSTER MOTHER/etc., no=0, yes=1, refused=6, no MOM or DAD=7, do not know=8
H1WP17D
0 49.630996
1 44.511070
6 0.092251
7 5.688807
8 0.076876
dtype: float64
A random sample of 6,504 adolescents were asked the following question, “Would you go out together in a group?” Of the total number, about 82.96% chose category 1 (Yes), and about 15.13% fell into category 2 (No). The majority of students that did not fall into category 2 refused to answer the question.
For the next question, the same students were asked “Do your parents let you make your own decisions about the people you hang around with?” About 83.33% chose category 1 (Yes), and about 14.48% fell into category 0 (No). The majority of students that did not fall into category 0 skipped the question legitimately (had no mom or dad).
For the next question, “Have you talked about someone you’re dating, or a party you went to with your MOTHER/ADOPTIVE MOTHER/STEPMOTHER/FOSTER MOTHER/etc.?” The majority (49.63%) replied No, and about 44.51 percent of students fell into category 1 (yes).