Skip to content

Instantly share code, notes, and snippets.

@bumatic
Last active January 4, 2022 06:19
Show Gist options
  • Save bumatic/83c3423595cde010da7ad059c6b8b2f5 to your computer and use it in GitHub Desktop.
Save bumatic/83c3423595cde010da7ad059c6b8b2f5 to your computer and use it in GitHub Desktop.
Notebook with widgets for interactively using PyCatFlow in a Jupyter Notebook.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
pycatflow
pandas
@ihmon
Copy link

ihmon commented Dec 12, 2021

Thank you very much for your notebook.
I think I will have oppotunity to use pycatflow in graph application, so I borrowed your notebook.
I run Step3 in your notebook with your sample dataset in my environment however following list index out of range error occurred.

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
/tmp/ipykernel_12628/3875842020.py in <module>
----> 1 data = pcf.read(raw_data, columns=viz_columns.value, 
      2                 nodes=viz_nodes.value, categories=viz_category.value,
      3                 column_order=viz_col_order.value)
      4 
      5 if data:

~/miniconda3/envs/edalab1/lib/python3.8/site-packages/pycatflow/input.py in read(data, columns, nodes, categories, column_order, orientation, delimiter, line_delimiter, prefix)
    211         for h in headers:
    212             # data[h] = [line.split(delimiter)[headers.index(h)] for line in lines]
--> 213             data[h.replace('\r', '')] = [line.split(delimiter)[headers.index(h)].replace('\r', '') for line in lines]
    214     if type(data) == list:
    215         headers = data[0]

~/miniconda3/envs/edalab1/lib/python3.8/site-packages/pycatflow/input.py in <listcomp>(.0)
    211         for h in headers:
    212             # data[h] = [line.split(delimiter)[headers.index(h)] for line in lines]
--> 213             data[h.replace('\r', '')] = [line.split(delimiter)[headers.index(h)].replace('\r', '') for line in lines]
    214     if type(data) == list:
    215         headers = data[0]

IndexError: list index out of range

Do you have any idea to solve this error?
Thank you,

FYI: following is assigned to raw_data variable. I changed delimiter to comma. but tab did not work too.

column,items,category,column order\n2015-09-08,fuzzywuzzy,A_Requirements,1\n2015-09-08,requests,A_Requirements,1\n2015-09-08,requests-oauthlib,A_Requirements,1\n2015-09-08,pymongo,A_Requirements,1\n2015-09-08,jsondatabase,A_Requirements,1\n2016-09-08,jsondatabase...

@bumatic
Copy link
Author

bumatic commented Dec 17, 2021

Thanks for your interest and for pointing me to the error. However, running the Notebook in mybinder.org and on my local machine, I was unable to replicate it.

Taking a closer look at step 3 I encountered that the delimiter was not passed on to the pcf.read function. This has been fixed. However, it shouldn’t have caused an error on the default setup and the example data since pcf.read tries to identify the delimiter based on heuristics and these heuristics work at least for the sample data.

One possible cause of your error could be that you run an outdated version of the package. Please make sure that you are running the current version of PyCatFlow.

For providing further assistance I need more detailed information.

Have you checked the output of the second code cell of step 1 (Execution counter 3 in the below image)? It should look something like this:

pycatflow

@ihmon
Copy link

ihmon commented Jan 4, 2022

Thank you for your response.
I ran all cells one by one and I don't think I missed something because your notebook is very user friendly.
I run the same code on Colab which I used at that time, and then I find it is no problem w/o any error. Everything is perfect. I have not changed anything, only difference is version of pycatflow.
I do not remember which version it was, but this time it is following.

"Successfully installed cairoSVG-2.5.2 cairocffi-1.3.0 cssselect2-0.4.1 drawSVG-1.8.3 pycatflow-0.0.8 tinycss2-1.1.1"

As you mentioned, version might have been old at that time.
I also checked the same code on my conda env w/ pycatflow-0.0.8, it is perfectly processed.

Thank you for your kindly support.
B.R,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment