Skip to main content

A package allowing to download datacubes into pandas data frames

Project description

pandas-datacube

About

pandas-datacube is a python package allowing to convert and download a datacube from a remote source using SPARQL](https://www.w3.org/TR/sparql11-overview/) queries and to obtain a pandas dataframe

Installation

You can install pandas-datacube from PyPi:

$ pip install pandas-datacube

How to use

The module is quite simple to use:

refArea refPeriod measureType gender workingPattern populationGroup median mean
0 http://statistics.gov.scot/id/statistical-geography/S92000003 http://reference.data.gov.uk/id/year/1997 http://statistics.gov.scot/def/measure-properties/median http://statistics.gov.scot/def/concept/gender/male http://statistics.gov.scot/def/concept/working-pattern/full-time http://statistics.gov.scot/def/concept/population-group/workplace-based 340.8
1 http://statistics.gov.scot/id/statistical-geography/S92000003 http://reference.data.gov.uk/id/year/1997 http://statistics.gov.scot/def/measure-properties/mean http://statistics.gov.scot/def/concept/gender/male http://statistics.gov.scot/def/concept/working-pattern/full-time http://statistics.gov.scot/def/concept/population-group/workplace-based 387.1
2 http://statistics.gov.scot/id/statistical-geography/S92000003 http://reference.data.gov.uk/id/year/1997 http://statistics.gov.scot/def/measure-properties/median http://statistics.gov.scot/def/concept/gender/male http://statistics.gov.scot/def/concept/working-pattern/part-time http://statistics.gov.scot/def/concept/population-group/workplace-based 80
3 http://statistics.gov.scot/id/statistical-geography/S92000003 http://reference.data.gov.uk/id/year/1997 http://statistics.gov.scot/def/measure-properties/mean http://statistics.gov.scot/def/concept/gender/male http://statistics.gov.scot/def/concept/working-pattern/part-time http://statistics.gov.scot/def/concept/population-group/workplace-based 110.9
4 http://statistics.gov.scot/id/statistical-geography/S92000003 http://reference.data.gov.uk/id/year/1997 http://statistics.gov.scot/def/measure-properties/median http://statistics.gov.scot/def/concept/gender/female http://statistics.gov.scot/def/concept/working-pattern/full-time http://statistics.gov.scot/def/concept/population-group/workplace-based 247
  • do all steps in one lines

    from pandasdatacube import get_datacube
    import pandas as pd
    
    ENDPOINT: str = "http://kaiko.getalp.org/sparql"
    PREFIXES: dict[str] = {'dbnary': 'http://kaiko.getalp.org/dbnary#',
                        'dbnstats': 'http://kaiko.getalp.org/dbnary/statistics/',
                        'lime': 'http://www.w3.org/ns/lemon/lime#'}
    
    dataset: str = "dbnstats:dbnaryStatisticsCube"
    dimensions: list[str] = ['dbnary:observationLanguage', 'dbnary:wiktionaryDumpVersion']
    mesures: list[str] = ['dbnary:lexicalEntryCount', 'dbnary:lexicalSenseCount', 'dbnary:pageCount', 'dbnary:translationsCount']
    dtypes: dict[str] = {"lexicalEntryCount": int, "translationsCount": int, "lexicalSenseCount": int, "pageCount": int}
    
    data: pd.DataFrame = get_datacube(ENDPOINT, dataset, dimensions, mesures, dtypes, PREFIXES)
    
    data.head().reset_index()
    
    observationLanguage wiktionaryDumpVersion lexicalEntryCount lexicalSenseCount pageCount translationsCount
    0 bg 20210701 18626 18420 27050 18086
    1 bg 20140224 18831 18798 27071 13888
    2 bg 20140312 18829 18796 27068 13895
    3 bg 20140328 18828 18795 27072 13909
    4 bg 20140415 18822 18294 27068 13920

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

pandas_datacube-0.0.2-py2.py3-none-any.whl (10.5 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page