https://github.com/atxtechbro/feddebtceiling
$911.91 per capita of federal debt was added to the nations balance sheet on October 14th as the lifting of the federal debt ceiling was followed by a surge of borrowing
https://github.com/atxtechbro/feddebtceiling
json pandas-tricks-for-data-manipulation python3 requests rest-api
Last synced: 7 months ago
JSON representation
$911.91 per capita of federal debt was added to the nations balance sheet on October 14th as the lifting of the federal debt ceiling was followed by a surge of borrowing
- Host: GitHub
- URL: https://github.com/atxtechbro/feddebtceiling
- Owner: atxtechbro
- Created: 2021-10-17T20:34:22.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-10-18T02:09:31.000Z (almost 4 years ago)
- Last Synced: 2025-01-25T21:28:02.793Z (8 months ago)
- Topics: json, pandas-tricks-for-data-manipulation, python3, requests, rest-api
- Language: Python
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# fedDebtCeiling
$911.91 was added to YOUR portion of the federal debt last week on just one day! Is that true? Let's test it out in Python using high quality federal data sourcesPython test framework - https://github.com/mojo-py/fedDebtCeiling
The code is short enough at about 25 lines to serve as it's own documentation, and includes a link to the official API documentation from Treasury Dept.In this short script, we take the following steps:
1) construct a parametized url
2) using the url, making a GET request from the US Treasury 'debt_to_penny' API endpoint
3) loading the response data into JSON
4) passing that response to create a pandas DataFrame object
5) shifting the dataframe back by 1 day to make a calculated column called ['netChange'] which is net daily debt change ie todays debt - yesterdays debt = df['netChange
6) calculating the quotient of the numerator (net daily debt change or $299,000,000,000) over the denominator, total USA population(population=328_239_523)
7) population / df.loc['2021-10-14']['netChange'] = result
8) apply string formatting to result and interpolate result into f-string and print it## evaluates as TRUE
Sources - >
US Census Bureau Population estimates, July 1, 2019, (V2019)
U.S. Department of the Treasury FiscalData Rest API https://api.fiscaldata.treasury.gov/services/api/fiscal_service/v2/accounting/od/debt_to_penny?fields=record_date,tot_pub_debt_out_amt&filter=record_date:gte:2021-08-01