Created
October 2, 2021 23:19
-
-
Save drozzy/b14fa996b95724f54a9b3be192691350 to your computer and use it in GitHub Desktop.
US Budgets adjusted for inflation, Data from https://www.presidency.ucsb.edu/statistics/data/federal-budget-receipts-and-outlays
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Year | Budget | |
|---|---|---|
| 1930 | 4.1 | |
| 1931 | 3.1 | |
| 1932 | 1.9 | |
| 1933 | 2.0 | |
| 1934 | 3.0 | |
| 1935 | 3.6 | |
| 1936 | 3.9 | |
| 1937 | 5.4 | |
| 1938 | 6.8 | |
| 1939 | 6.3 | |
| 1940 | 6.5 | |
| 1941 | 8.7 | |
| 1942 | 14.6 | |
| 1943 | 24.0 | |
| 1944 | 43.7 | |
| 1945 | 45.2 | |
| 1946 | 39.3 | |
| 1947 | 38.5 | |
| 1948 | 41.6 | |
| 1949 | 39.4 | |
| 1950 | 39.4 | |
| 1951 | 51.6 | |
| 1952 | 66.2 | |
| 1953 | 69.6 | |
| 1954 | 69.7 | |
| 1955 | 65.5 | |
| 1956 | 74.6 | |
| 1957 | 80.0 | |
| 1958 | 79.6 | |
| 1959 | 79.2 | |
| 1960 | 92.5 | |
| 1961 | 94.4 | |
| 1962 | 99.7 | |
| 1963 | 106.6 | |
| 1964 | 112.6 | |
| 1965 | 116.8 | |
| 1966 | 130.8 | |
| 1967 | 148.8 | |
| 1968 | 153.0 | |
| 1969 | 186.9 | |
| 1970 | 192.8 | |
| 1971 | 187.1 | |
| 1972 | 207.3 | |
| 1973 | 230.8 | |
| 1974 | 263.2 | |
| 1975 | 279.1 | |
| 1977 | 355.6 | |
| 1978 | 399.6 | |
| 1979 | 463.3 | |
| 1980 | 517.1 | |
| 1981 | 599.3 | |
| 1982 | 617.8 | |
| 1983 | 600.6 | |
| 1984 | 666.4 | |
| 1985 | 734.0 | |
| 1986 | 769.2 | |
| 1987 | 854.3 | |
| 1988 | 909.2 | |
| 1989 | 991.1 | |
| 1990 | 1032.0 | |
| 1991 | 1055.0 | |
| 1992 | 1091.2 | |
| 1993 | 1154.3 | |
| 1994 | 1258.6 | |
| 1995 | 1351.8 | |
| 1996 | 1453.1 | |
| 1997 | 1579.2 | |
| 1998 | 1721.7 | |
| 1999 | 1827.5 | |
| 2000 | 2025.2 | |
| 2001 | 1991.1 | |
| 2002 | 1853.1 | |
| 2003 | 1782.3 | |
| 2004 | 1880.1 | |
| 2005 | 2153.6 | |
| 2006 | 2406.9 | |
| 2007 | 2568.0 | |
| 2008 | 2524.0 | |
| 2009 | 2105.0 | |
| 2010 | 2162.7 | |
| 2011 | 2303.5 | |
| 2012 | 2450.0 | |
| 2013 | 2775.1 | |
| 2014 | 3021.5 | |
| 2015 | 3249.9 | |
| 2016 | 3268.0 | |
| 2017 | 3316.2 | |
| 2018 | 3329.9 | |
| 2019 | 3463.4 | |
| 2020 | 3421.2 | |
| 2021 | 3580.8 | |
| 2022 | 4174.2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| import cpi | |
| import altair as alt | |
| df = pd.read_csv('budget.csv', sep=',', index_col=False) | |
| years = [] | |
| adjusted = [] | |
| for _, row in df.iterrows(): | |
| years.append(row['Year']) | |
| try: | |
| a = cpi.inflate(row['Budget'], int(row['Year'])) | |
| except cpi.errors.CPIObjectDoesNotExist: | |
| # No data for 2019 and later, assume: | |
| if row['Year'] == 2021: | |
| inflation = 1.04 | |
| else: | |
| inflation = 1.02 | |
| a = row['Budget'].item()*inflation | |
| adjusted.append(a) | |
| xticks = [y for y in range(1930, 2021, 3)] | |
| data = pd.DataFrame({'Year': years, 'Budget': adjusted}) | |
| chart = alt.Chart(data, width=800).mark_line().encode( | |
| x=alt.X('Year:O', axis=alt.Axis(values=xticks)), | |
| y=alt.Y('Budget:Q', title='Budget (Billions)') | |
| ).properties( | |
| title="US Budgets Adjusted for Inflation (1930-2021)" | |
| ) | |
| chart.save('budget.png') | |
Author
My friend I don't remember anymore :) Feel free to use the script to double check!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why 1.04 for 2021? Since it's the latest year, shouldn't it be just 1? Or is the CPI value from Jan. 2022 now the reference value?