Want to improve your Python, Git, and Pandas skills in a small group that I personally mentor — with a clear syllabus and tons of practice? Cohort 8 of my Python Data Analysis Bootcamp (PythonDAB) will start on December 4th. Watch the recorded info session at https://www.youtube.com/watch?v=pTDP9rSv75Y, or sign up for an interview at https://savvycal.com/reuven/pythondab . Full bootcamp info is at https://PythonDAB.com .
How is the US economy doing? That's an easy question to ask, and a hard one to answer briefly, mostly because there are so many variables to take into account.
On the one hand, you could say that it's going pretty well, with the stock market up overall, and unemployment relatively low. But you could also say that it's going pretty poorly, with (slowly) growing unemployment, inflation ticking up, and people remaining in their jobs for fear of having trouble finding another one. The Trump Administration's chaotic approach to international trade and tariffs, along with their large-scale deportations, have introduced large levels of uncertainty.
(This sort of answer is the reason why it's said President Truman wanted to meet a one-handed economist.)
There are numerous ways to measure the health of an economy. Among them are:
- The S&P500 index, measuring the stock prices of 500 different public companies (SP500)
- The yield of 10-year Treasury notes, aka US government bonds (IRLTLT01USM156N)
- The "Fed funds" interest rates, set by the Federal Reserve to achieve its dual mandate, maximizing employment and minimizing inflation (FEDFUNDS)
- Inflation, measured as PCE, aka "personal consumption expenditures," excluding food and energy (DPCCRV1Q225SBEA)
- Oil prices, using the West Texas Intermediate price (DCOILWTICO)
- University of Michigan's consumer sentiment measure (UMCSENT)
- The price of gold, measured via the import price of nonmonetary gold (IR14270)
- The price of bitcoin, as measured by Coinbase (CBBTCUSD)
These measures are obviously connected to one another. Higher inflation will likely lead to worse consumer sentiment, and also to higher interest rates from the Federal Reserve, which will in turn lead to lower stock prices and higher unemployment. But with hundreds of millions of people and billions of transactions among consumers and businesses, you won't find a perfect correlation between any of these.
But that doesn't mean we cannot and should not try. This week, we'll thus use Marimo and Plotly to create a data dashboard that shows us the eight indicators I listed above. We'll see each indicator on its own, but also in a scatterplot to try to find correlations among them.
Oh, and why include Bitcoin in this mix? I'm a Bitcoin skeptic, and don't believe it really indicates much... but a lot of people own Bitcoin, and it's theoretically unconnected to other market measures. We'll see if that's true.
Data and five questions
This week's data all comes from Fred, the amazing data portal from the St. Louis Federal Reserve Bank, at https://fred.stlouisfed.org/ . Each data source on Fred has a unique name. You'll use the fredapi Python package to retrieve eight data sources, and then present them in a variety of ways. Note that to use the fredapi package, you will need a Fred API key, which you can get for free from https://fred.stlouisfed.org/docs/api/api_key.html .
Because the data will all come from Fred, and will be retrieved via the fredapi package, there aren't any data files to download this week.
Learning goals this week include working with APIs, handling multiple data inputs, interpolation,
Paid subscribers – including members of my LernerPython+data membership program at https://LernerPython.com – get access to all questions and answers, downloadable notebooks, and a one-click access to my notebook at Marimo's Molab. You also get invited to monthly office hours, like the ones we had earlier this week.
Here are this week's five questions and tasks; I'll be back tomorrow with my solutions and explanations:
- Define a Python dict whose keys are the Fred indicators in parentheses, and whose values are English-language descriptions of those indicators. Use that dict and the
fredapiPython package to create a data frame with one column per dict key-value pair; the key will indicate the source of the data from Fred, and the value will be the column name. Resample to get the mean value per month for each indicator, then interpolate to removeNaNvalues. - Display a line plot showing all of the columns, each in a different color. Use Marimo's UI elements (checkboxes and a UI dictionary) to let the user choose which columns of the data frame should (and shouldn't) be displayed.