Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Data Science Basics Charts and Tables Tables

Alex Peck
Alex Peck
6,907 Points

Is 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
James Barber
3,502 Points

Check 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

'''