LogoLogo
Data CataloguePacificMapPDH.statMicrodata Library
  • Pacific Data Hub
    • Change Log
  • Data Catalogue
    • User Guide
      • Creating a new account
    • Advanced Search
      • Solr Search Queries
    • API
  • PacificMap
    • User Guide
  • PDH.stat
    • Data Explorer
    • Plugins
      • Excel
      • Power BI
      • R
      • Python
      • STATA
    • API
      • Interface
      • Use cases
      • Sample code
  • Microdata Library
    • User Guide
Powered by GitBook
On this page
  • Overview
  • Install sdmx
  • Connect to PDH.stat

Was this helpful?

Export as PDF
  1. PDH.stat
  2. Plugins

Python

Access Pacific data with the most popular data science solution using the pandasdmx library

PreviousRNextSTATA

Last updated 4 years ago

Was this helpful?

Overview

PDH.stat is part of the sdmx Python package developed by Paul Natsuo Kishimoto. More information about the package can be found .

Install sdmx

These steps have been tested with Python 3.7.4 in an Anaconda environment on Windows 10.

To install with pip from the command prompt (note: include the '1' at the end of sdmx): pip install sdmx1

In a Python project, import the package: import sdmx

Connect to PDH.stat

To see the available sources and find PDH.stat:

import sdmx
sdmx.list_sources()

The source abbreviation for PDH.stat is "SPC" (Pacific Community), as shown below.

To connect to PDH.stat and then view its available data flows:

spc = sdmx.Client('SPC')
datasets = sdmx.to_pandas(spc.dataflow().dataflow)
datasets

To connect to a data flow and convert it into a pandas Multi-index series:

data = spc.data('DF_CPI')
df = sdmx.to_pandas(data)
df

And then to turn the series into a dataframe, reset the index:

df = df.reset_index()
df

Start by installing sdmx. To learn more about the package, see the code .

For an example of how to use the plugin in combination with the API key and parameter settings, see the .

here
here
time series plot example