lec-11-6

lec-11-6 - controls The map ± Yet another crazy aspect of...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
11/6/2009 1 ECS 10 11/06 Announcements ± Final program due Tuesday, Nov 10. Dictionary of Lists ± Adding data to dictionary of lists. ± Dumping out all the data in the dictionary using a for loop. ± And now….writing a file for Many Eyes. Using Many Eyes ± Free registration. ± Upload data. ± Visualize using Country Map option. Many Eyes Many Eyes
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
11/6/2009 2 Many Eyes Many Eyes Input File Format ± It wants Tab Separated Values ± Columns within a line are separated by tabs ± Tab in Python is ‘\t’, just like newline is ‘\n’ Lines should end in newline ` n’ ± Lines should end in newline \n ± First line contains names of columns ± Known as .tsv ± Can be read in Excel, Google docs… Upload to Many Eyes ± Open file with Notepad (right-click, Open with Notepad if it opens with Excel when clicked). ± Scrape data with mouse – be sure to get it all! ± Paste into box Paste into box. ± Be sure to use Many Eyes outside class Web page (not inside frame). You get a lot more
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: controls! The map ± Yet another crazy aspect of our democracy. List of Lists ± When we dump our lists out of the dictionary they are in no particular order. ± Doesn’t matter for this project. ± But what if we want to print them out in some order? Imposing order ± How do we rank states by votes per million, or by population, or by alphabetical order? ± Put the data into a list, then use the sort() method. popList.sort() ± Rearranges the list! 11/6/2009 3 Organizing dictionary data ± Dump dictionary of lists into list of lists. ± Then sort that. ± List of lists: LoL = [ [2 3] [5 2] [1 6] [2 6] LoL = [ [2,3], [5,2], [1,6],[2,6] ] ± What is LoL [0]? Sorting by votes per million LoL= for state in popDict: dataList = popDict[state] pop = dataList[0] votes = dataList[1] ratio = (votes/pop)*1000000 LoL = LoL+[[ratio,state]] LoL.sort() for item in LoL: print item...
View Full Document

This note was uploaded on 01/14/2010 for the course ECS 10 taught by Professor Amenta during the Spring '07 term at UC Davis.

Page1 / 3

lec-11-6 - controls The map ± Yet another crazy aspect of...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online