Python
Access Pacific data with the most popular data science solution using the pandasdmx library
Last updated
PDH.stat is part of the sdmx
Python package developed by Paul Natsuo Kishimoto. More information about the package can be found here.
These steps have been tested with Python 3.7.4 in an Anaconda environment on Windows 10.
Start by installing sdmx. To learn more about the package, see the code here.
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
To see the available sources and find PDH.stat:
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:
To connect to a data flow and convert it into a pandas Multi-index series:
And then to turn the series into a dataframe, reset the index:
For an example of how to use the plugin in combination with the API key and parameter settings, see the time series plot example.