Opportunity Through Data Textbook
  • Opportunity Through Data Textbook
  • Introduction
    • What is Data Science?
    • Introduction to Data Science: Exploratory Musical Analysis
  • Module 1
    • Introduction to Programming
      • The Command Line
      • Installing Programs
      • Python and the Command Line
      • Jupyter Notebook
    • Introduction to Python
      • Building Blocks of Python - Data Types and Variables
      • Functions
      • Formatting and Syntax
    • Math Review
      • Variables and Functions
      • Intro to Graphs
  • Module 2
    • Data Structures
      • Lists
      • Dictionaries
      • Tables
    • Programming Logic
      • Loops
      • Logical Operators
      • Conditionality
  • Module 3
    • Introduction to Probability
      • Probability and Sampling
    • Introduction to Statistics
      • Mean & Variance
      • Causality & Randomness
  • Module 4
    • Packages
    • Intro to NumPy
      • NumPy (continued)
  • Module 5
    • Introduction to Pandas
      • Introduction to Dataframes
      • Groupby and Join
    • Working with Data
    • Data Visualization
      • Matplotlib
      • Introduction to Data Visualization
  • Appendix
    • Table Utilities
    • Area of More Complicated Shapes
    • Introduction to Counting
    • Slope and Distance
    • Short Circuiting
    • Linear Regression
    • Glossary
  • Extension: Classification
    • Classification
    • Test Sets and Training Sets
    • Nearest Neighbors
  • Extension: Introduction to SQL
    • Introduction to SQL
    • Table Operations
      • Tables and Queries
      • Joins
  • Extension: Central Limit Theorem
    • Overview
    • Probability Distributions
      • Bernoulli Distribution
      • Uniform Distribution (Discrete)
      • Random Variables, Expectation, Variance
      • Discrete and Continuous Distributions
      • Uniform Distribution (Continuous)
      • Normal Distribution
    • Central Limit Theorem in Action
    • Confidence Intervals
  • Extension: Object-Oriented Programming
    • Object-Oriented Programming
      • Classes
      • Instantiation
      • Dot Notation
      • Mutability
  • Extension: Introduction to Excel
    • Introduction to Excel
      • Terminology and Interface
      • Getting Started with Analysis and Charts
      • Basics of Manipulating Data
    • Additional Features in Excel
      • Macros
      • The Data Tab
      • Pivot Tables
Powered by GitBook
On this page
  • visualize_table(table)
  • bar(table, x, y)
  • line(table, x, y)

Was this helpful?

  1. Appendix

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:

>>> fruit = {
    'fruit': 
        ['apple', 'orange', 'peach'], 
    'price': 
        [1.49, 1.49, 2.49]
}
>>> bar(fruit, 'fruit', 'price')
# input 1: the table; input 2: the x-axis column name; 
# input 3: the y-axis column name

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:

>>> population = {
    'year': 
        [1900, 1905, 1910, 1915], 
    'population': 
        [123432, 126743, 134894, 156483]
}
>>> line(population, 'year', 'population')
# input 1: the table; input 2: the x-axis column name; 
# input 3: the y-axis column name
PreviousIntroduction to Data VisualizationNextArea of More Complicated Shapes

Last updated 5 years ago

Was this helpful?