Write States
Please Log In for full access to the web site.
Note that this link will take you to an external site (https://shimmer.mit.edu) to authenticate, and then you will be redirected back to this page.
Table of Contents
1) Introduction
You were doing so well as Chief Trade Officer (CTO) of the U.S. Commerce Department that your boss asked you to produce a report summarizing your findings. The problems below will continue your work in the previous exercise.
2) Make Database Rows
Your next step is to fill in the body of the make_rows
function. When given
the tiny_database
as an input, this function should produce the following
list of lists:
[
['State', 'Total Exports Value', '# Export Transactions', 'Average ETV', 'Median ETV', 'ETV std'],
['CA', 30106, 3, 10035.333333333334, 12462.0, 6470.518492018669],
['MA', 59878, 2, 29939.0, 29939.0, 17158.0],
['MT', 24274, 2, 12137.0, 12137.0, 11553.0],
['ND', 13566, 3, 4522.0, 1456.0, 5381.157929913103],
['SC', 41, 1, 41.0, 41.0, 0.0],
['WY', 128633, 1, 128633.0, 128633.0, 0.0],
]
Note that ETV stands for Export Transaction Value. You are encouraged to use numpy to calculate the average, median, and standard deviation.
Please remember to convert the average, median, and standard deviation to a float. The server will return an error that says "Your code did not run to completion, but no error message was returned. This normally means that your code contains an infinite loop or otherwise took too long to run." if your rows contain numpy.float64 numbers.
When your code does this, and passes the third test case in the test.py
file,
upload your code below:
make_rows
function
3) Write Database
Now that we can make the rows of the database, the final step is writing the
large summary database to a csv file. You may want to fill in the body of
the write_database
function to help with this task.
The first handful of rows of your output file should look like the following:
![](https://smatz.mit.edu/_static/6s090/week4/write_states/large_csv.png)
Note that the numbers can be integers or floats, the checker will verify that the rows are in the same order and that the values in each row are equal.
4) CSV Upload
Next Exercise: (Optional but Encouraged!) 100 Doors