Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hmelberg/stats-to-pandas
Download data from statistical agencies to pandas dataframes.
https://github.com/hmelberg/stats-to-pandas
Last synced: about 18 hours ago
JSON representation
Download data from statistical agencies to pandas dataframes.
- Host: GitHub
- URL: https://github.com/hmelberg/stats-to-pandas
- Owner: hmelberg
- License: other
- Created: 2016-06-16T00:08:09.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-10-16T22:41:02.000Z (about 4 years ago)
- Last Synced: 2024-08-09T20:43:09.266Z (3 months ago)
- Language: Jupyter Notebook
- Homepage: https://github.com/hmelberg/stats-to-pandas/tree/master/notebooks
- Size: 529 KB
- Stars: 9
- Watchers: 3
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# stats-to-pandas
Download data from statistical agencies to pandas dataframes.[Demo on YouTube](https://www.youtube.com/watch?v=hhj7ITIU3F8)
## Installation
pip install stats_to_pandas
## Requirements
- pandas
- requests
- pyjstat
- Jupyter notebook, IPython, ipywidgets## Overview
##### 0. Import package
import stats_to_pandas as stp
##### 1. Search for tables based on keywordsstp.search('cows')
##### 2. Select a table id from the dataframe and create a gui-box to select the variables to be included
(Works when the user is in a jupyter notebook and has widgets installed)box = stp.select(table_id = '10714')
##### 3. Read the variable selection from the gui-box and download the data from Statistics Norway
df = stp.read_box(box)
## 4. More
##### Read all values for all variables for table with id 10714
(Avoid having to select variables, step 2 above, but may result in large tables)df = stp.read_all(table_id = '10714')
##### Get the json string for a full query of table number 10714
query = stp.full_json(table_id = '10714', out = 'str')
##### Get the json dict for a full query of table number 10714
query = stp.full_json(table_id = '10714', out = 'dict')
##### Get the json dict associated with the current selection from a widget box
query = stp.get_json(box)
##### Read data from Statistics Ireland
irl_url = 'http://www.cso.ie/StatbankServices/StatbankServices.svc/jsonservice/responseinstance/CNA31'
df = stp.read_url(full_url = irl_url)