Class 15, Monday, February 19
CSV Chrestomathics
Make sure what you know — Be sure you know what you know — Know now that you know
Look both ways
Agenda
- CSV chrestomathics
- Expanded url.py (redownload it now)
Datasets de jeur
Book, Author, Language, Date, Sales
Don Quixote, de Cervantes, Spanish, 1605, 500000000
A Tale of Two Cities, Dickens, English, 1859, 200000000
The Lord of the Rings, Tolkien, English, 1954, 150000000
The Little Prince, de Saint-Exupéry, French, 1943, 140000000
Harry Potter and the Philosopher's Stone, Rowling, English, 1997, 120000000
The Hobbit, Tolkien, English, 1937, 100000000
And Then There Were None, Christie, English, 1939, 100000000
Dream of the Red Chamber, Xueqin, Chinese, 1754, 100000000
Alice's Adventures in Wonderland, Carroll, English, 1865, 100000000
Location, Author, Max Height, Min Height
Narnia, Lewis, 4810, -10
Neverland, Milne, 426, -2
Oz, Baum, 1231, 679
Sleep Hollow, Irving, 1629, 304
Stars Hollow, Sherman-Palladino, 725, 152
Toyland, MacDonough, 6187, 0
Wonderland, Carroll, 5895, -5
Country, Females, Males, Continent
Afghanistan, 15160172, 16251571, Asia
Albania, 1599688, 1604596, Europe
Algeria, 17567864, 17900344, Africa
Angola, 9632075, 9449837, Africa
Argentina, 20643969, 19768407, South America
Armenia, 1652892, 1439180, Europe
Australia, 11175724, 11092660, Oceania
...
Example
- Analyzes a dataset of best selling fiction
- analyze_dataset.py — for a user-specified dataset, and two user-specified column labels
column1
andcolumn2
:
- Determines the minimum value
min2
for thecolumn2
of the dataset
- Determines
min_label
— thecolumn1
value for the row whosecolumn2
value ismin2
- Prints labeled explanatory information about
min2
- Sample runs
Enter the name of a data set: elevations.csv
Enter a column label for the data set: Author
Enter a column label for the data set: Max Height
Min Max Height: 426
Author: Milne
Enter the name of a data set: countries.csv
Enter a column label for the data set: Country
Enter a column label for the data set: Males
Min Males: 101778
Country: Mayotte
Enter the name of a data set: best-sellers.csv
Enter a column label for the data set: Language
Enter a column label for the data set: Book
Min Date: 1605
Book: Don Quixote
To do
- Review class artifacts
- Review standard documentation for built-in functions.
- Review course documentation for module str.
- Review course documentation for module list.
- Review course documentation for local module url.
- Review standard documentation for module math.
- Review ccourse documentation for module random.
- Epistle on syntax errors and exceptions.
- Epistle on accomplishments.
Another dataset
Type,Name,Population,Male,Female,Households,Total Housing Units,Owner-occupied
A,Accomack County,38305,18590,19715,15299,19550,11482
A,Albemarle County,79236,38002,41234,31876,33720,20991
A,Alleghany County,12926,6450,6476,5149,5812,4369
A,Amelia County,11400,5622,5778,4240,4609,3474
A,Amherst County,31894,15208,16686,11941,12958,9325
A,Appomattox County,13705,6671,7034,5322,5828,4315
A,Arlington County,189453,95443,94010,86352,90426,37370
A,Augusta County,65615,32995,32620,24818,26738,20628
...
Warning: fopen(/l/cs1112/public_html/defs/htm/181-trailer): Failed to open stream: No such file or directory in /l/cs1112/public_html/defs/php/read.php on line 5
Unable to open file!