Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NotImplementedError when using Eurostat's DSD #242

Open
mephinet opened this issue Mar 17, 2023 · 1 comment
Open

NotImplementedError when using Eurostat's DSD #242

mephinet opened this issue Mar 17, 2023 · 1 comment
Labels

Comments

@mephinet
Copy link

I recently upgraded to pandasdmx[cache]>=1.10.0 after the recent Eurostat API change.
At the same time, I improved my code to follow the walkthrough document and use structure-specific data.

However, now I run into a NotImplementedError when accessing Eurostat.

The minimal reproducer is:

import pandasdmx

estat = pandasdmx.Request("ESTAT")
resource_id = "demo_gind"
flow_msg = estat.dataflow(resource_id)
dsd = flow_msg.dataflow[resource_id.upper()].structure
data = estat.data(resource_id=resource_id, dsd=dsd)

When I remove the dsd argument from the data call, the code runs without issues.

@beto-Sibileau
Copy link

Hi @dr-leo, adding some more references to this one, essentially the same error to a similar flow:

  • request a datastructure using pdsdmx library
  • request data to Eurostat new API (XML structure-specific)
  • use pdsdmx.read_sdmx() method with same output error: NotImplementedError: ('{urn:sdmx:org.sdmx.infomodel.datastructure.DataStructure=ESTAT:HLTH_SILC_08(33.0):ObsLevelDim:TIME_PERIOD}DataSet', 'start')

Code snippet below:

import io

import pandasdmx as pdsdmx
import requests

# pdsdmx requests objet (ESTAT)
Estat = pdsdmx.Request("ESTAT")
# ESTAT dataflow
d_flow = "hlth_silc_08".upper()

# ESTAT structure query (pdsdmx)
Dsd_estat = Estat.datastructure(d_flow)

# ESTAT data query
api_param = {
    "startPeriod": "2022",
    "endPeriod": "2022",
    "format": "SDMX_2.1_STRUCTURED",
}
url_estat = f"https://ec.europa.eu/eurostat/api/dissemination/sdmx/2.1/data/{d_flow}/.PC..NO_UNMET...BE+BG"
indicator_xml = requests.get(url_estat, api_param, timeout=15)

buffer_read = io.BufferedReader(io.BytesIO(indicator_xml.content))

try:
    xml_message = pdsdmx.read_sdmx(
        buffer_read, format="XML", dsd=Dsd_estat.structure[d_flow]
    )
    data_df = xml_message.to_pandas(dtype=str, attributes="o", rtype="rows")
    print("OK")
except Exception as error:
    print(error)

@dr-leo dr-leo added the wontfix label Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants