FDIC Failed Banks coding assignment for Public Affairs Data Journalism.
- Learn how to use Python libraries, work with text files and download remote files
- Apply a growing set of practical Python skills to the FDIC failed banks data
The skills covered in the tutorials below are needed to complete the Failed Banks assignment. Be sure to carefully work through these before attempting the coding assignment.
Learn how to:
- Use code libraries included with Python or offered by third parties
- Work with text files
- Work with CSVs
- Download remote files
You may also want to work through the Python Syntax Crash Course again if you're feeling shaky on basics such as variables, conditionals, loops, etc.
Please make sure to have carefully worked through the Python tutorials mentioned above before attempting this portion of the assignment.
The goal of this assignment is to:
- Create a CSV containing failed banks in CA based on the FDIC Failed Banks list.
- Print the number of failed banks in CA to the shell
For this assignment, you must create a single Python script (NOT a Jupyter Notebook) to achieve the goals described above.
Additionally, you must "reformat", or convert, the Closing Date field to a standard format.
To help you get started, we've created an empty script called failed_banks_ca.py. It includes details on the required steps.
Please read the script carefully before starting to code.
Your job is to flesh out failed_banks_ca.py in all the spots where there is a TODO.
The steps are detailed in the script, but here's an overview with links to relevant documentation on each task:
- Use Python's
requestslibrary to download and save a copy of the FDIC failed banks CSV. Make sure to name the filebanklist.csv. You don't need to use the CSV module for this step. It's preferable to just use standard file writing techniques.
- Use Python to "read" the local
banklist.csvand generate a new CSV calledfailed_banks_ca.csv. You must use the csv module for these steps. The file must contain only failed banks in California. It should have the same header row and columns as the source data. And you must convert theClosing Datevalues to a date formatted asYYYY-MM-DD(e.g.2020-01-29). You'll need to use strptime and strftime from the datetime module to perform the conversion. - Create a new text file called
ca_failed_banks_summary.txt. Write the following simple sentence to the text file, replacing theXwith the actual count of failed banks in California:There are X failed banks in CA. For example:There are 41 failed banks in CA.. The count (X) should be calculated with code "dynamically". DO NOT hard-code a number that you determined using some other strategy (e.g. opening the file in Excel). You might find it helpful to learn about string formatting for this part of the assignment.
- You must use standard file writing techniques and the CSV module. Do not use
pandasor other third-party libraries - After submitting code, be sure to check the
Actionstab in GitHub repository to see if there are any errors. The auto-grader will be red if there are issues, or green if all checks passed successfully.
- We've provided you with a starter script with guidance on specific techniques. But we're throwing a lot of new skills at you with this assignment. Make sure you take the time to practice each of these skills (e.g. in JupyterLite or Codespaces) before trying to apply them in this assignment.
- Use
printstatements in your script to get visibility into the code.
Once the script is complete, you must use Codespaces to stage, commit and sync your changes to your code repository.
IMPORTANT: Always make sure you stage/commit/sync your changes before leaving the Codespace, even if your work is only partially complete. Otherwise you risk losing your work.
Lastly, to officially submit, grab the URL to your personal assignment repository and submit it via Canvas.