Table Utilities

In order to make it easier for you to visualize tables and create graphs, we've created a few utility functions! The following describe what they do and how they work.

visualize_table(table)

This function takes in a table and displays it! For example, the table:

Fruit

Price

"apple"

1.49

"orange"

1.49

"peach"

2.49

Can be written as:

fruit = {
    'fruit': 
        ['apple', 'orange', 'peach'], 
    'price': 
        [1.49, 1.49, 2.49]
}

Calling visualize_table on fruit would produce the following:

>>> visualize_table(fruit)

    fruit  price
0   apple   1.49
1  orange   1.49
2   peach   2.49

bar(table, x, y)

If you want to graph categorical data, you can use the bar function; it produces a bar graph given a table, the x-axis column, and the y-axis column. If the following table is fruit:

Fruit

Price

"apple"

1.49

"orange"

1.49

"peach"

2.49

Calling the bar function would do the following:

line(table, x, y)

If you want to graph two different kinds of numerical data against each other, you can use the line function; it produces a line graph given a table, the x-axis column, and the y-axis column. If the following table is population:

Year

Population

1900

123,432

1905

126,743

1910

134,894

1915

156,483

Calling the line function would do the following:

Last updated

Was this helpful?