Hi everyone,
I am struggling with my solution seemingly not matching what the dataquest lesson is requesting.
Lesson: Working With Strings In Pandas, Screen 11/13
My Code:
merged['IncomeGroup'] = merged['IncomeGroup'].str.upper() \
.str.replace(r'(INCOME)?(:)?', '') \
.str.replace(r' ', ' ')
pv_incomes = merged.pivot_table(index = 'IncomeGroup',
values = 'Happiness Score')
pv_incomes.plot(kind = 'bar',
rot = 30,
ylim = (0,10))
Solution Code:
merged['IncomeGroup'] = merged['IncomeGroup'].str.replace(' income', '').str.replace(':', '').str.upper()
pv_incomes = merged.pivot_table(values='Happiness Score', index='IncomeGroup')
pv_incomes.plot(kind='bar', rot=30, ylim=(0,10))
plt.show()
What actually happened:
Do any of you have an idea of what the difference is in the result of my code and the solution code?