Let's use the following sequence of steps to import the data and start our exploration of this dataset in Python:
- With the following snippet, we will create a Python list in memory that contains dictionaries of each row, where the keys are the column names (the first row of the CSV contains the header information) and the values are the values for that particular row:
In : import csv ...: data_file = "../data/income_dist.csv" ...: with open(data_file, 'r') as csvfile: ...: reader = csv.DictReader(csvfile) ...: data = list(reader)
Note that the input file, income_dist.csv, might be in a different directory in your system depending on where you place it.
- We perform a quick check with len to reveal the number of records: ...