Convert some data into Panda DataFrames
British Petroleum (BP)
It parse sheet like Primary Energy Consumption (not like Primary Energy - Cons by fuel).
Open: http://www.bp.com/statisticalreview or https://www.bp.com/en/global/corporate/energy-economics/statistical-review-of-world-energy.html
Download Statistical Review of World Energy – all data.
Use:
from shifter_pandas.bp import UNITS_ENERGY, BPDatasource
shifter_ds = BPDatasource("bp-stats-review-2021-all-data.xlsx")
df = shifter_ds.datasource(units_filter=UNITS_ENERGY, regions_filter=["Switzerland"])
df
Swiss Office Federal of Statistics (OFS)
From https://www.bfs.admin.ch/bfs/fr/home/services/recherche/stat-tab-donnees-interactives.html create a stat table.
Click on À propos du tableau
Click on Rendez ce tableau disponible dans votre application
Use:
from shifter_pandas.ofs import OFSDatasource
shifter_ds = OFSDatasource("<URL>")
df = shifter_ds.datasource(<Requête Json>)
df
And replace <URL> and <Requête Json> with the content of the fields of the OFS web page.
Interesting sources
- Parc de motocycles par caractéristiques techniques et émissions
- Bilan démographique selon l'âge et le canton
Our World in Data
Select a publication.
Click Download.
Click Full data (CSV).
Use:
import pandas as pd
from shifter_pandas.wikidata_ import WikidataDatasource
df_owid = pd.read_csv("<file name>")
wdds = WikidataDatasource()
df_wd = wdds.datasource_code(wikidata_id=True, wikidata_name=True, wikidata_type=True)
df = pd.merge(df_owid, df_wd, how="inner", left_on='iso_code', right_on='Code')
df
Interesting sources
World Bank
Open https://data.worldbank.org/
Find a chart
In Download click CSV
Use:
from shifter_pandas.worldbank import wbDatasource
df = wbDatasource("<file name>")
df
Interesting sources
Wikidata
By providing the wikidata_* parameters, you can ass some data from WikiData.
Careful, the WikiData is relatively slow then the first time you run it il will be slow. We use a cache to make it fast the next times.
You can also get the country list with population and ISO 2 code with:
from shifter_pandas.wikidata_ import (
ELEMENT_COUNTRY,
PROPERTY_ISO_3166_1_ALPHA_2,
PROPERTY_POPULATION,
WikidataDatasource,
)
shifter_ds = WikidataDatasource()
df = shifter_ds.datasource(
instance_of=ELEMENT_COUNTRY,
with_id=True,
with_name=True,
properties=[PROPERTY_ISO_3166_1_ALPHA_2, PROPERTY_POPULATION],
limit=1000,
)
df
Contributing
Install the pre-commit hooks:
pip install pre-commit
pre-commit install --allow-missing-config
Metadata
Release files for shifter-pandas 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| shifter_pandas-1.0.3.tar.gz | 14.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| shifter_pandas-1.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 29.4 kB
Release files / shifter_pandas-1.0.3.tar.gz
| Download URL | shifter_pandas-1.0.3.tar.gz |
|---|---|
| Size | 14.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
52cd71d6766d9917b40bc1e67c13e67f1464d7ef16e9624bd081eb084b2b6bcb
|
|
BLAKE2b-256 checksum How to use checksums |
535b5de0b1f0b521424cb7fe6c909baaca9c3c1074dd4e80e59b6d1c90e9a6d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.13.0
|
Release files / shifter_pandas-1.0.3-py3-none-any.whl
| Download URL | shifter_pandas-1.0.3-py3-none-any.whl |
|---|---|
| Size | 15.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fe80a76a5d99833e2943868b30271952513cc3672e1de86a6e88b78f65882778
|
|
BLAKE2b-256 checksum How to use checksums |
7bfca0411e19a10d582af7278f164d6948e26ec5c1ea7664da2b8fbcb1957cec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.13.0
|