microsoft / vscode-jupyter

VS Code Jupyter extension
https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter
MIT License
1.3k stars 293 forks source link

cant visualize data of a valid DF #14713

Open ieCecchetti opened 1 year ago

ieCecchetti commented 1 year ago

Applies To

What happened?

Im debugging my code on VSCode. I start my code with: pytest -K 'TestClass' -v and I have my breakpoints after the df acquisition. I can assure that the df is valid cause i can normally print it fully or a slice and obtaining this:

     identifier     activity_state                                      business_name  ... knowledge_state date_debut_activite date_fin_activite
0    IDF9300028        Ne sait pas  MIROITERIE ART WILSON ; MEERT (SARL) ; BARNABE...  ...      Inventorié          1944-01-01        1987-12-31
1    PAC1301845  Activité terminée                                   SOCIETE ROSE THE  ...      Inventorié          1952-01-01              None
2    BRE5600735  Activité terminée  ADESHYOUT STE, usine de déshydratation des fou...  ...      Inventorié          1974-09-16        1111-01-01
3    AQI4701087  Activité terminée                                           Orsettig  ...      Inventorié          1111-01-01        1997-01-01
4    CSC2A04308        En activité                                               SECA  ...      Inventorié          2006-01-03              None
..          ...                ...                                                ...  ...             ...                 ...               ...
495  RHA7302316               None                  Sté PAN - EUROPEENNE (Européenne)  ...      Inventorié          1969-12-10              None
496  RHA7302188               None                                          M. VACHER  ...      Inventorié          1925-06-06              None
497  MPY3232340  Activité terminée                  SICTON SUD-EST / DECHARGE SAUVAGE  ...      Inventorié          1111-01-01              None
498  RHA7302274               None  Sté d'Equipement de la Région de Chambéry (Dir...  ...      Inventorié          1969-02-12              None
499  RHA7302455  Activité terminée  Le Caoutchouc Industriel de Rochassieux (PDG: ...  ...      Inventorié          1954-06-04              None

[500 rows x 7 columns]

I downloaded the datas from here

and parsed as df = pd.read_xml(xml_content, namespaces=used_namespaces, xpath=xpath_filter)

When i try to use the function to show the df (View value in DataViewer) I encounter errors. I never lunched jupiter as notebook but im only using normal py code. So i dont have a .ipynb file I know that the extention should work too for visualize the data content. right? or am i wrong?

Someone knows whats happening?

VS Code Version

1.84.2

Jupyter Extension Version

v2023.10.1003070148

Jupyter logs

22:05:44.607 [error] [SyntaxError: Unexpected token ''', "'{"shape":"... is not valid JSON
    at JSON.parse (<anonymous>)
    at Rw.getFullVariable (~\.vscode\extensions\ms-toolsai.jupyter-2023.10.1003070148-win32-x64\out\extension.node.js:24:280400)
    at async XE.onVariablePanelShowDataViewerRequest (~\.vscode\extensions\ms-toolsai.jupyter-2023.10.1003070148-win32-x64\out\extension.node.js:24:588263)
    at async i.h (~\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:125:139661)]
22:05:44.607 [warn] DataScience Error [SyntaxError: Unexpected token ''', "'{"shape":"... is not valid JSON
    at JSON.parse (<anonymous>)
    at Rw.getFullVariable (~\.vscode\extensions\ms-toolsai.jupyter-2023.10.1003070148-win32-x64\out\extension.node.js:24:280400)
    at async XE.onVariablePanelShowDataViewerRequest (~\.vscode\extensions\ms-toolsai.jupyter-2023.10.1003070148-win32-x64\out\extension.node.js:24:588263)
    at async i.h (~\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:125:139661)]

Coding Language and Runtime Version

No response

Language Extension Version (if applicable)

3.9

Anaconda Version (if applicable)

No response

Running Jupyter locally or remotely?

None

amunger commented 1 year ago

yes, that should work similar to how the data viewer is opened for notebook variables. It sounds like there's some character in there that we don't handle, but I'm not seeing anything when taking a quick glance at the xml file.

ieCecchetti commented 1 year ago

I will give you more info to reproduce it. the xml is parsed with the use of these variables:

XPATH = "//gml:featureMember/*"
NAMESPACE = {
    "ms": "http://mapserver.gis.umn.edu/mapserver",
    "gml": "http://www.opengis.net/gml",
    "wfs": "http://www.opengis.net/wfs",
    "ogc": "http://www.opengis.net/ogc",
    "xsi": "http://www.w3.org/2001/XMLSchema-instance"
}

and the istruction used is: df = pd.read_xml(xml_content, namespaces=NAMESPACE , xpath=XPATH )

the variable xml content is given as:

xml = requests.get(my_url).content
if isinstance(xml, str):
    xml_content = io.StringIO(xml)
elif isinstance(xml, bytes):
    xml_content = io.BytesIO(xml)
else;
   .... exeption
amunger commented 11 months ago

similar issues https://github.com/microsoft/vscode-jupyter/issues/13363 https://github.com/microsoft/vscode-jupyter/issues/13619