CS105
LAB 9- Python and Data Visualization


Objectives
  1. Using Python to create a dataset from an existing database
  2. How to visualize data: many-eyes


Creating a Dataset from an Existing Database

We want to write a program that creates a dataset containing the number of films in various runtime ranges. (60-69 min, 70-79 min, etc.)
- Between 60 - 69 minutes
- Between 70 - 79 minutes
- Between 80 - 89 minutes
- Between 90 - 99 minutes
- Between 100 - 109 minutes
- and so on

In writing your script, use this template which already includes the code for connecting to database. (Simply right click on the link and select 'save target as'. Then save it to your working directory.)

In writing your code, use a for loop which will execute 18 times, i.e. for each runtime range. In each execution of the for loop:
- Use two variables lower and upper initialised to 60 and 69 respectively.
- Then increment lower and upper by 10 each in the for loop
- Perform the related query for the runtime range.
- Write the result of the query for that range on the screen.

Finally you will have a simple table like this:

Run Time # Films
Between 60 - 69 ...
Between 70 - 79 ..
Between 80 - 89 ..
Between 90 - 99 ..
Between 100 - 109 ..
Between 110 - 119  
and so on ...  

In the next part, we will try to interpret this data.


Data Visualization

Many-eyes is a kind of data visualization tool which can be found at http://www.many-eyes.com/
By using many-eyes, you can load your own data to the system, and visualize it with any type of chart you want. You can also publish your charts by using this website.

How can we visualize and interpret the data, which we found as a result of the question in the previous part?

Now, let's go to many-eyes web site, load our data into the system and visualize our data.

In order to load your own data, you have to register to the system. Don't worry, it doesn't take so much time.

After registering, login to the system and click on "Create Visualization" from the left menu.

Then, select "upload your own dataset".

Fill in the form. You can use this excel sheet to copy your own data to the text area.

When you click on upload after filling the form, you will be directed to a page where you can select the type of chart among a bunch of choices.

What kind of chart is convenient for your data? Bar chart, pie chart?

 

CS105