{"id":64,"date":"2020-08-28T16:35:17","date_gmt":"2020-08-28T16:35:17","guid":{"rendered":"https:\/\/jeremywhittaker.com\/?p=64"},"modified":"2021-09-22T20:59:01","modified_gmt":"2021-09-22T20:59:01","slug":"getting-st-louis-fred-data-in-google-colab-for-python-analysis","status":"publish","type":"post","link":"https:\/\/new.jeremywhittaker.com\/index.php\/2020\/08\/28\/getting-st-louis-fred-data-in-google-colab-for-python-analysis\/","title":{"rendered":"Getting St. Louis FRED Data in Google Colab for Python Analysis"},"content":{"rendered":"\n<p>At times when creating trading strategies using big data you need access to historical economic data. One of the best sources of data is the Economic Research branch of the St. Louis Federal Reserve or <a href=\"https:\/\/fred.stlouisfed.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">FRED<\/a>. Today I&#8217;m going to show you how to pull that data into a dataframe so that you can analyze it using machine learning or AI. <\/p>\n\n\n\n<p>The first step is to import <a href=\"https:\/\/pandas-datareader.readthedocs.io\/en\/latest\/\" target=\"_blank\" rel=\"noreferrer noopener\">Pandas datareader<\/a>. What this piece of code does is it downloads all the data for <a href=\"https:\/\/fred.stlouisfed.org\/series\/DAAA\" target=\"_blank\" rel=\"noreferrer noopener\">Corporate AAA bond yields<\/a>. Every dataset in FRED has a symobl. In this case it&#8217;s DAAA. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import pandas_datareader.data as web\r\nimport datetime\r\n\r\ntoday = pd.to_datetime(\"today\")\r\nstart = datetime.datetime(1900, 1, 1)\r\nend = today\r\n\r\ndf_Corp_AAA_yield = web.DataReader(&#91;'DAAA'], 'fred', start, end)\r\n\r\n# not working - Corp_AAA_yield = web.DataReader(&#91;'DAAA'], 'fred', start, end)\r\ndf_Corp_AAA_yield.head()\r\ndf_Corp_AAA_yield.tail()\r\n<\/code><\/pre>\n\n\n\n<p>We can now visualize our dataframe by plotting it. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>df_Corp_AAA_yield.plot(grid=True)<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"467\" height=\"279\" data-src=\"https:\/\/new.jeremywhittaker.com\/wp-content\/uploads\/2020\/08\/image-12.png\" alt=\"\" class=\"wp-image-65 lazyload\" data-srcset=\"https:\/\/new.jeremywhittaker.com\/wp-content\/uploads\/2020\/08\/image-12.png 467w, https:\/\/new.jeremywhittaker.com\/wp-content\/uploads\/2020\/08\/image-12-300x179.png 300w\" data-sizes=\"(max-width: 467px) 100vw, 467px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 467px; --smush-placeholder-aspect-ratio: 467\/279;\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>At times when creating trading strategies using big data you need access to historical economic data. One of the best sources of data is the Economic Research branch&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-64","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Getting St. Louis FRED Data in Google Colab for Python Analysis - Jeremy Whittaker<\/title>\n<meta name=\"robots\" content=\"noindex, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Getting St. Louis FRED Data in Google Colab for Python Analysis - Jeremy Whittaker\" \/>\n<meta property=\"og:description\" content=\"At times when creating trading strategies using big data you need access to historical economic data. One of the best sources of data is the Economic Research branch...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/new.jeremywhittaker.com\/index.php\/2020\/08\/28\/getting-st-louis-fred-data-in-google-colab-for-python-analysis\/\" \/>\n<meta property=\"og:site_name\" content=\"Jeremy Whittaker\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/WhittakerJeremy\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/WhittakerJeremy\" \/>\n<meta property=\"article:published_time\" content=\"2020-08-28T16:35:17+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-09-22T20:59:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/new.jeremywhittaker.com\/wp-content\/uploads\/2020\/08\/image-12.png\" \/>\n<meta name=\"author\" content=\"JeremyWhittaker\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"JeremyWhittaker\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/new.jeremywhittaker.com\/index.php\/2020\/08\/28\/getting-st-louis-fred-data-in-google-colab-for-python-analysis\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/new.jeremywhittaker.com\/index.php\/2020\/08\/28\/getting-st-louis-fred-data-in-google-colab-for-python-analysis\/\"},\"author\":{\"name\":\"JeremyWhittaker\",\"@id\":\"https:\/\/new.jeremywhittaker.com\/#\/schema\/person\/ed0edfdefb3e180693efef453372980c\"},\"headline\":\"Getting St. Louis FRED Data in Google Colab for Python Analysis\",\"datePublished\":\"2020-08-28T16:35:17+00:00\",\"dateModified\":\"2021-09-22T20:59:01+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/new.jeremywhittaker.com\/index.php\/2020\/08\/28\/getting-st-louis-fred-data-in-google-colab-for-python-analysis\/\"},\"wordCount\":120,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/new.jeremywhittaker.com\/#\/schema\/person\/ed0edfdefb3e180693efef453372980c\"},\"image\":{\"@id\":\"https:\/\/new.jeremywhittaker.com\/index.php\/2020\/08\/28\/getting-st-louis-fred-data-in-google-colab-for-python-analysis\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/new.jeremywhittaker.com\/wp-content\/uploads\/2020\/08\/image-12.png\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/new.jeremywhittaker.com\/index.php\/2020\/08\/28\/getting-st-louis-fred-data-in-google-colab-for-python-analysis\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/new.jeremywhittaker.com\/index.php\/2020\/08\/28\/getting-st-louis-fred-data-in-google-colab-for-python-analysis\/\",\"url\":\"https:\/\/new.jeremywhittaker.com\/index.php\/2020\/08\/28\/getting-st-louis-fred-data-in-google-colab-for-python-analysis\/\",\"name\":\"Getting St. Louis FRED Data in Google Colab for Python Analysis - Jeremy Whittaker\",\"isPartOf\":{\"@id\":\"https:\/\/new.jeremywhittaker.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/new.jeremywhittaker.com\/index.php\/2020\/08\/28\/getting-st-louis-fred-data-in-google-colab-for-python-analysis\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/new.jeremywhittaker.com\/index.php\/2020\/08\/28\/getting-st-louis-fred-data-in-google-colab-for-python-analysis\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/new.jeremywhittaker.com\/wp-content\/uploads\/2020\/08\/image-12.png\",\"datePublished\":\"2020-08-28T16:35:17+00:00\",\"dateModified\":\"2021-09-22T20:59:01+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/new.jeremywhittaker.com\/index.php\/2020\/08\/28\/getting-st-louis-fred-data-in-google-colab-for-python-analysis\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/new.jeremywhittaker.com\/index.php\/2020\/08\/28\/getting-st-louis-fred-data-in-google-colab-for-python-analysis\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/new.jeremywhittaker.com\/index.php\/2020\/08\/28\/getting-st-louis-fred-data-in-google-colab-for-python-analysis\/#primaryimage\",\"url\":\"https:\/\/new.jeremywhittaker.com\/wp-content\/uploads\/2020\/08\/image-12.png\",\"contentUrl\":\"https:\/\/new.jeremywhittaker.com\/wp-content\/uploads\/2020\/08\/image-12.png\",\"width\":467,\"height\":279},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/new.jeremywhittaker.com\/index.php\/2020\/08\/28\/getting-st-louis-fred-data-in-google-colab-for-python-analysis\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/new.jeremywhittaker.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Getting St. Louis FRED Data in Google Colab for Python Analysis\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/new.jeremywhittaker.com\/#website\",\"url\":\"https:\/\/new.jeremywhittaker.com\/\",\"name\":\"Jeremy Whittaker\",\"description\":\"Research, software, markets, housing, and energy\",\"publisher\":{\"@id\":\"https:\/\/new.jeremywhittaker.com\/#\/schema\/person\/ed0edfdefb3e180693efef453372980c\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/new.jeremywhittaker.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/new.jeremywhittaker.com\/#\/schema\/person\/ed0edfdefb3e180693efef453372980c\",\"name\":\"JeremyWhittaker\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/c8ac20e6dfa86b5f27ce9bffee4851099770cbea5ae7338a274865bfbc8c0218?s=96&d=retro&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c8ac20e6dfa86b5f27ce9bffee4851099770cbea5ae7338a274865bfbc8c0218?s=96&d=retro&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c8ac20e6dfa86b5f27ce9bffee4851099770cbea5ae7338a274865bfbc8c0218?s=96&d=retro&r=g\",\"caption\":\"JeremyWhittaker\"},\"logo\":{\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/c8ac20e6dfa86b5f27ce9bffee4851099770cbea5ae7338a274865bfbc8c0218?s=96&d=retro&r=g\"},\"sameAs\":[\"http:\/\/www.jeremywhittaker.com\",\"https:\/\/www.facebook.com\/WhittakerJeremy\",\"https:\/\/www.linkedin.com\/in\/jeremywhittaker\/\"],\"url\":\"https:\/\/new.jeremywhittaker.com\/index.php\/author\/jeremywhittaker\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Getting St. Louis FRED Data in Google Colab for Python Analysis - Jeremy Whittaker","robots":{"index":"noindex","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"og_locale":"en_US","og_type":"article","og_title":"Getting St. Louis FRED Data in Google Colab for Python Analysis - Jeremy Whittaker","og_description":"At times when creating trading strategies using big data you need access to historical economic data. One of the best sources of data is the Economic Research branch...","og_url":"https:\/\/new.jeremywhittaker.com\/index.php\/2020\/08\/28\/getting-st-louis-fred-data-in-google-colab-for-python-analysis\/","og_site_name":"Jeremy Whittaker","article_publisher":"https:\/\/www.facebook.com\/WhittakerJeremy","article_author":"https:\/\/www.facebook.com\/WhittakerJeremy","article_published_time":"2020-08-28T16:35:17+00:00","article_modified_time":"2021-09-22T20:59:01+00:00","og_image":[{"url":"https:\/\/new.jeremywhittaker.com\/wp-content\/uploads\/2020\/08\/image-12.png","type":"","width":"","height":""}],"author":"JeremyWhittaker","twitter_card":"summary_large_image","twitter_misc":{"Written by":"JeremyWhittaker","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/new.jeremywhittaker.com\/index.php\/2020\/08\/28\/getting-st-louis-fred-data-in-google-colab-for-python-analysis\/#article","isPartOf":{"@id":"https:\/\/new.jeremywhittaker.com\/index.php\/2020\/08\/28\/getting-st-louis-fred-data-in-google-colab-for-python-analysis\/"},"author":{"name":"JeremyWhittaker","@id":"https:\/\/new.jeremywhittaker.com\/#\/schema\/person\/ed0edfdefb3e180693efef453372980c"},"headline":"Getting St. Louis FRED Data in Google Colab for Python Analysis","datePublished":"2020-08-28T16:35:17+00:00","dateModified":"2021-09-22T20:59:01+00:00","mainEntityOfPage":{"@id":"https:\/\/new.jeremywhittaker.com\/index.php\/2020\/08\/28\/getting-st-louis-fred-data-in-google-colab-for-python-analysis\/"},"wordCount":120,"commentCount":0,"publisher":{"@id":"https:\/\/new.jeremywhittaker.com\/#\/schema\/person\/ed0edfdefb3e180693efef453372980c"},"image":{"@id":"https:\/\/new.jeremywhittaker.com\/index.php\/2020\/08\/28\/getting-st-louis-fred-data-in-google-colab-for-python-analysis\/#primaryimage"},"thumbnailUrl":"https:\/\/new.jeremywhittaker.com\/wp-content\/uploads\/2020\/08\/image-12.png","inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/new.jeremywhittaker.com\/index.php\/2020\/08\/28\/getting-st-louis-fred-data-in-google-colab-for-python-analysis\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/new.jeremywhittaker.com\/index.php\/2020\/08\/28\/getting-st-louis-fred-data-in-google-colab-for-python-analysis\/","url":"https:\/\/new.jeremywhittaker.com\/index.php\/2020\/08\/28\/getting-st-louis-fred-data-in-google-colab-for-python-analysis\/","name":"Getting St. Louis FRED Data in Google Colab for Python Analysis - Jeremy Whittaker","isPartOf":{"@id":"https:\/\/new.jeremywhittaker.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/new.jeremywhittaker.com\/index.php\/2020\/08\/28\/getting-st-louis-fred-data-in-google-colab-for-python-analysis\/#primaryimage"},"image":{"@id":"https:\/\/new.jeremywhittaker.com\/index.php\/2020\/08\/28\/getting-st-louis-fred-data-in-google-colab-for-python-analysis\/#primaryimage"},"thumbnailUrl":"https:\/\/new.jeremywhittaker.com\/wp-content\/uploads\/2020\/08\/image-12.png","datePublished":"2020-08-28T16:35:17+00:00","dateModified":"2021-09-22T20:59:01+00:00","breadcrumb":{"@id":"https:\/\/new.jeremywhittaker.com\/index.php\/2020\/08\/28\/getting-st-louis-fred-data-in-google-colab-for-python-analysis\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/new.jeremywhittaker.com\/index.php\/2020\/08\/28\/getting-st-louis-fred-data-in-google-colab-for-python-analysis\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/new.jeremywhittaker.com\/index.php\/2020\/08\/28\/getting-st-louis-fred-data-in-google-colab-for-python-analysis\/#primaryimage","url":"https:\/\/new.jeremywhittaker.com\/wp-content\/uploads\/2020\/08\/image-12.png","contentUrl":"https:\/\/new.jeremywhittaker.com\/wp-content\/uploads\/2020\/08\/image-12.png","width":467,"height":279},{"@type":"BreadcrumbList","@id":"https:\/\/new.jeremywhittaker.com\/index.php\/2020\/08\/28\/getting-st-louis-fred-data-in-google-colab-for-python-analysis\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/new.jeremywhittaker.com\/"},{"@type":"ListItem","position":2,"name":"Getting St. Louis FRED Data in Google Colab for Python Analysis"}]},{"@type":"WebSite","@id":"https:\/\/new.jeremywhittaker.com\/#website","url":"https:\/\/new.jeremywhittaker.com\/","name":"Jeremy Whittaker","description":"Research, software, markets, housing, and energy","publisher":{"@id":"https:\/\/new.jeremywhittaker.com\/#\/schema\/person\/ed0edfdefb3e180693efef453372980c"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/new.jeremywhittaker.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/new.jeremywhittaker.com\/#\/schema\/person\/ed0edfdefb3e180693efef453372980c","name":"JeremyWhittaker","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/c8ac20e6dfa86b5f27ce9bffee4851099770cbea5ae7338a274865bfbc8c0218?s=96&d=retro&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/c8ac20e6dfa86b5f27ce9bffee4851099770cbea5ae7338a274865bfbc8c0218?s=96&d=retro&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c8ac20e6dfa86b5f27ce9bffee4851099770cbea5ae7338a274865bfbc8c0218?s=96&d=retro&r=g","caption":"JeremyWhittaker"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/c8ac20e6dfa86b5f27ce9bffee4851099770cbea5ae7338a274865bfbc8c0218?s=96&d=retro&r=g"},"sameAs":["http:\/\/www.jeremywhittaker.com","https:\/\/www.facebook.com\/WhittakerJeremy","https:\/\/www.linkedin.com\/in\/jeremywhittaker\/"],"url":"https:\/\/new.jeremywhittaker.com\/index.php\/author\/jeremywhittaker\/"}]}},"_links":{"self":[{"href":"https:\/\/new.jeremywhittaker.com\/index.php\/wp-json\/wp\/v2\/posts\/64","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/new.jeremywhittaker.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/new.jeremywhittaker.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/new.jeremywhittaker.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/new.jeremywhittaker.com\/index.php\/wp-json\/wp\/v2\/comments?post=64"}],"version-history":[{"count":0,"href":"https:\/\/new.jeremywhittaker.com\/index.php\/wp-json\/wp\/v2\/posts\/64\/revisions"}],"wp:attachment":[{"href":"https:\/\/new.jeremywhittaker.com\/index.php\/wp-json\/wp\/v2\/media?parent=64"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/new.jeremywhittaker.com\/index.php\/wp-json\/wp\/v2\/categories?post=64"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/new.jeremywhittaker.com\/index.php\/wp-json\/wp\/v2\/tags?post=64"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}