Skip to content
Course Notes: Data Types for Data Science in Python
  • AI Chat
  • Code
  • Report
  • Course Notes

    Use this workspace to take notes, store code snippets, and build your own interactive cheatsheet!

    Note that the data from the course is not yet added to this workspace. You will need to navigate to the course overview page, download any data you wish to use, and add it to the file browser.

    # Import any packages you want to use here
    

    Take Notes

    Add notes here about the concepts you've learned and code cells with code you want to keep.

    Add your notes here

    # Add your code snippets here
    

    CSV to Dict

    # Import the python CSV module
    import csv 
    
    # Create a python file object in read mode for the baby_names.csv file: csvfile
    csvfile = open ("baby_names.csv","r")
    
    # Loop over a csv reader on the file object
    for row in csv.DictReader(csvfile):
        # Print each row 
        print(row)
        # Add the rank and name to the dictionary: baby_names
        baby_names[row["RANK"]] = row["NAME"]
    
    # Print the dictionary keys
    print (baby_names.keys())