Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAlex Peck
6,907 PointsIs anyone else who is working locally with the zip download getting a bar plot, but no table?
I'm using the download zip files and working locally. It's been fine for every lesson in the course until now. Even when I copy and paste the entire code from the workspace (with additions made in the video) I can't get my local dev setup to produce the table, only the bar plot.
Screenshot: https://www.evernote.com/l/AMfBdv0rLk9KYZuWZFcr78XYBNuSyBIwjmc
However, when I do the lesson in the browser workspace the code works.
I can't figure out what I'm missing and any you could provide would be a appreciated.
Thanks!
1 Answer
James Barber
3,502 PointsCheck your build_table_text() function. I had a similar issue but resolved it by revising this function. Here's the code that works for me (and shows the table properly), be especially watchful of your indentation (previously, my return was indented too far, which caused my table to be limited to the first row...). NOTE: Notice the code before the code block below, not sure how to fix the markdown in my post...:
'''python
def build_table_text(data_sample, brands): cell_text = [] row_text = []
unique_brand_list = sorted(set(brands))
for brand in unique_brand_list:
brand = bytes.decode(brand)
temp_row = []
group1 = count_prices_for_brands(data_sample, brand, 0, 50)
group2 = count_prices_for_brands(data_sample, brand, 50, 100)
group3 = count_prices_for_brands(data_sample, brand, 100, 150)
group4 = count_prices_for_brands(data_sample, brand, 150, 200)
group5 = count_prices_for_brands(data_sample, brand, 200, 250)
group6 = count_prices_for_brands(data_sample, brand, 250, 10000)
row_list = [group1, group2, group3, group4, group5, group6]
temp_row.extend(row_list)
if group1 > 0:
if any([x >= group1 for x in row_list[1:]]):
cell_text.append(temp_row)
row_text.append(brand)
return cell_text, row_text
'''