def income(string):
    if pd.isnull(string) == True:
        return None
    else:
        string = string.split(' ')[0]
        if string == 'Prefer':
            return None
        string = string.replace('$', '')
        string = string.replace(',', '')
        return int(string)
data['int_income'] = data['How much total combined money did all members of your HOUSEHOLD earn last year?'].apply(income)
data['int_income'].describe()

print(data['How much total combined money did all members of your HOUSEHOLD earn last year?'].value_counts())

"""
Explanation: Despite the fact that we have rounded off the age, the data reflects the present proportions of age groups (the same proportions as in [9])
End of explanation
"""


data[data['int_income'] < 50000]['How far will you travel for Thanksgiving?'].value_counts(normalize=True)

data[data['int_income'] >= 150000]['How far will you travel for Thanksgiving?'].value_counts(normalize=True)

"""
Explanation: When analyzing this result, it should be borne in mind that we took only the lower value of each group. Also, we have a very high standard deviation (59 thousand dollars) with the step size of each group of 25 thousand.
End of explanation
"""


table = pd.pivot_table(data, values='int_age', index='Have you ever tried to meet up with hometown friends on Thanksgiving night?', columns='Have you ever attended a "Friendsgiving?"')
table

table_income = pd.pivot_table(data, values='int_income', index='Have you ever tried to meet up with hometown friends on Thanksgiving night?', columns='Have you ever attended a "Friendsgiving?"')
table_income

"""
Explanation: Only 38 percent of the respondents (with an income of 50000 thousand) celebrate at home. At the same time, 47 percent of respondents (with an income of 150 and above) celebrate at home. Despite not much difference, we can assume that students prefer to celebrate a holiday in the home of parents who earn more (and accordingly, celebrate in their own home).
End of explanation
"""


none1 = data['Which of these desserts do you typically have at Thanksgiving dinner? Please select all that apply.   - Other (please specify)'].value_counts()
none2 = data['Which of these desserts do you typically have at Thanksgiving dinner? Please select all that apply.   - Other (please specify).1'].value_counts()

none1

none2

data['Which of these desserts do you typically have at Thanksgiving dinner? Please select all that apply.   - Peach cobbler'].value_counts()

"""
Explanation: It appears that young people prefer to meet up with friends on Thanksgiving and try to attend a "Friendsgiving? (We can make this conclusion  from pivot tables: people who do this have less age (33.9) and income(66019))
Figure out the most common dessert people eat.
End of explanation
"""


