shifter-pandas


Nameshifter-pandas JSON
Version 1.0.2 PyPI version JSON
download
home_pagehttps://hub.docker.com/r/sbrunner/shifter-pandas/
SummaryConvert some data into Panda DataFrames
upload_time2024-12-04 11:23:38
maintainerNone
docs_urlNone
authorStéphane Brunner
requires_python>=3.13
licenseBSD-2-Clause
keywords shifter pandas
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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:

```python
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:

```python
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](https://www.pxweb.bfs.admin.ch/pxweb/fr/px-x-1103020100_165/-/px-x-1103020100_165.px/)
- [Bilan démographique selon l'âge et le canton](https://www.pxweb.bfs.admin.ch/pxweb/fr/px-x-0102020000_104/-/px-x-0102020000_104.px/)

## Our World in Data

Select a publication.

Click `Download`.

Click `Full data (CSV)`.

Use:

```python
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

- [GDP, 1820 to 2018](https://ourworldindata.org/grapher/gdp-world-regions-stacked-area)
- [Population, 1800 to 2021](https://ourworldindata.org/grapher/population-since-1800)

## World Bank

Open https://data.worldbank.org/

Find a chart

In `Download` click `CSV`

Use:

```python
from shifter_pandas.worldbank import wbDatasource

df = wbDatasource("<file name>")
df
```

### Interesting sources

- [GDP (current US$)](https://data.worldbank.org/indicator/NY.GDP.MKTP.CD)
- [GDP (constant 2015 US$)](https://data.worldbank.org/indicator/NY.GDP.MKTP.KD)

## 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:

```python
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:

```bash
pip install pre-commit
pre-commit install --allow-missing-config
```


            

Raw data

            {
    "_id": null,
    "home_page": "https://hub.docker.com/r/sbrunner/shifter-pandas/",
    "name": "shifter-pandas",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.13",
    "maintainer_email": null,
    "keywords": "shifter, pandas",
    "author": "St\u00e9phane Brunner",
    "author_email": "stephane.brunner@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/44/b4/f15d5599d5cfcb30fdaf49dc4383cde3a0e6a2accd21ddb5dfb01a3653d8/shifter_pandas-1.0.2.tar.gz",
    "platform": null,
    "description": "# Convert some data into Panda DataFrames\n\n## British Petroleum (BP)\n\nIt parse sheet like `Primary Energy Consumption` (not like `Primary Energy - Cons by fuel`).\n\nOpen: http://www.bp.com/statisticalreview\nor https://www.bp.com/en/global/corporate/energy-economics/statistical-review-of-world-energy.html\n\nDownload `Statistical Review of World Energy \u2013 all data`.\n\nUse:\n\n```python\nfrom shifter_pandas.bp import UNITS_ENERGY, BPDatasource\n\nshifter_ds = BPDatasource(\"bp-stats-review-2021-all-data.xlsx\")\n\ndf = shifter_ds.datasource(units_filter=UNITS_ENERGY, regions_filter=[\"Switzerland\"])\ndf\n```\n\n## Swiss Office Federal of Statistics (OFS)\n\nFrom https://www.bfs.admin.ch/bfs/fr/home/services/recherche/stat-tab-donnees-interactives.html\ncreate a stat table.\n\nClick on `\u00c0 propos du tableau`\n\nClick on `Rendez ce tableau disponible dans votre application`\n\nUse:\n\n```python\nfrom shifter_pandas.ofs import OFSDatasource\n\nshifter_ds = OFSDatasource(\"<URL>\")\n\ndf = shifter_ds.datasource(<Requ\u00eate Json>)\ndf\n```\n\nAnd replace `<URL>` and `<Requ\u00eate Json>` with the content of the fields of the OFS web page.\n\n### Interesting sources\n\n- [Parc de motocycles par caract\u00e9ristiques techniques et \u00e9missions](https://www.pxweb.bfs.admin.ch/pxweb/fr/px-x-1103020100_165/-/px-x-1103020100_165.px/)\n- [Bilan d\u00e9mographique selon l'\u00e2ge et le canton](https://www.pxweb.bfs.admin.ch/pxweb/fr/px-x-0102020000_104/-/px-x-0102020000_104.px/)\n\n## Our World in Data\n\nSelect a publication.\n\nClick `Download`.\n\nClick `Full data (CSV)`.\n\nUse:\n\n```python\nimport pandas as pd\nfrom shifter_pandas.wikidata_ import WikidataDatasource\n\ndf_owid = pd.read_csv(\"<file name>\")\nwdds = WikidataDatasource()\ndf_wd = wdds.datasource_code(wikidata_id=True, wikidata_name=True, wikidata_type=True)\ndf = pd.merge(df_owid, df_wd, how=\"inner\", left_on='iso_code', right_on='Code')\ndf\n```\n\n### Interesting sources\n\n- [GDP, 1820 to 2018](https://ourworldindata.org/grapher/gdp-world-regions-stacked-area)\n- [Population, 1800 to 2021](https://ourworldindata.org/grapher/population-since-1800)\n\n## World Bank\n\nOpen https://data.worldbank.org/\n\nFind a chart\n\nIn `Download` click `CSV`\n\nUse:\n\n```python\nfrom shifter_pandas.worldbank import wbDatasource\n\ndf = wbDatasource(\"<file name>\")\ndf\n```\n\n### Interesting sources\n\n- [GDP (current US$)](https://data.worldbank.org/indicator/NY.GDP.MKTP.CD)\n- [GDP (constant 2015 US$)](https://data.worldbank.org/indicator/NY.GDP.MKTP.KD)\n\n## Wikidata\n\nBy providing the `wikidata_*` parameters, you can ass some data from WikiData.\n\nCareful, the WikiData is relatively slow then the first time you run it il will be slow.\nWe use a cache to make it fast the next times.\n\nYou can also get the country list with population and ISO 2 code with:\n\n```python\nfrom shifter_pandas.wikidata_ import (\n    ELEMENT_COUNTRY,\n    PROPERTY_ISO_3166_1_ALPHA_2,\n    PROPERTY_POPULATION,\n    WikidataDatasource,\n)\n\nshifter_ds = WikidataDatasource()\ndf = shifter_ds.datasource(\n    instance_of=ELEMENT_COUNTRY,\n    with_id=True,\n    with_name=True,\n    properties=[PROPERTY_ISO_3166_1_ALPHA_2, PROPERTY_POPULATION],\n    limit=1000,\n)\ndf\n```\n\n## Contributing\n\nInstall the pre-commit hooks:\n\n```bash\npip install pre-commit\npre-commit install --allow-missing-config\n```\n\n",
    "bugtrack_url": null,
    "license": "BSD-2-Clause",
    "summary": "Convert some data into Panda DataFrames",
    "version": "1.0.2",
    "project_urls": {
        "Homepage": "https://hub.docker.com/r/sbrunner/shifter-pandas/",
        "Repository": "https://github.com/sbrunner/shifter-pandas"
    },
    "split_keywords": [
        "shifter",
        " pandas"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a4fa6dcdd27ccc182f0a1c77b38bb3a92e4aa7b34acaa3a5e993f5436e0a6c95",
                "md5": "8731fadb4b4183e4a1c8a20d0985c92c",
                "sha256": "114a29fc3c2b8a74dca22e8567ede7eed0e8cd32ae1e32f59c9385d3f4c0ddd8"
            },
            "downloads": -1,
            "filename": "shifter_pandas-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8731fadb4b4183e4a1c8a20d0985c92c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.13",
            "size": 14961,
            "upload_time": "2024-12-04T11:23:37",
            "upload_time_iso_8601": "2024-12-04T11:23:37.257550Z",
            "url": "https://files.pythonhosted.org/packages/a4/fa/6dcdd27ccc182f0a1c77b38bb3a92e4aa7b34acaa3a5e993f5436e0a6c95/shifter_pandas-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "44b4f15d5599d5cfcb30fdaf49dc4383cde3a0e6a2accd21ddb5dfb01a3653d8",
                "md5": "18117dfacbb253fd15fe645e88e6b39f",
                "sha256": "d1149d6a7a7dfdc91babb96cab3340a36bfbd14b48b56ccc3098b70e34279d57"
            },
            "downloads": -1,
            "filename": "shifter_pandas-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "18117dfacbb253fd15fe645e88e6b39f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.13",
            "size": 14453,
            "upload_time": "2024-12-04T11:23:38",
            "upload_time_iso_8601": "2024-12-04T11:23:38.824864Z",
            "url": "https://files.pythonhosted.org/packages/44/b4/f15d5599d5cfcb30fdaf49dc4383cde3a0e6a2accd21ddb5dfb01a3653d8/shifter_pandas-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-04 11:23:38",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sbrunner",
    "github_project": "shifter-pandas",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "shifter-pandas"
}
        
Elapsed time: 0.47263s