Git Product home page Git Product logo

plotly-converter's Introduction

ubi-center

Generates data for UBI Center's Plan Explorer tool and visualizations.

Installation

Install with:

pip install git+git://github.com/UBICenter/ubi-center.git

Questions

Contact the maintainer, Max Ghenis ([email protected]).

Citation

You may cite the source of your analysis as "ubicenter release #.#.#, author's calculations."

plotly-converter's People

Contributors

mgilbert1 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

plotly-converter's Issues

Issue producing HTML files from panda DataFrame

Error when running plotly-converter on https://blog.ubicenter.org/20201214/canada-homelessness-experiment.html

Error message:
Traceback (most recent call last):
File "C:\Users\yuchi\src\UBI-Center\blog\jb\20201214\make_graphs.py", line 14, in
io.write_html(fig, "../../plotly-converter/assets/graphs/2020-12-14-canada-homelessness-experiment-graph1.html", full_html = False, include_plotlyjs = False)
NameError: name 'fig' is not defined
File "C:\Users\yuchi\src\UBI-Center\blog\jb\20201214\make_graphs.py", line 70
io.write_html(fig, "../../plotly-converter/assets/graphs/2020-12-14-canada-homelessness-experiment-graph2.html", full_html = False, include_plotlyjs = False)
^
SyntaxError: invalid syntax
Traceback (most recent call last):
File "C:\Users\yuchi\src\UBI-Center\blog\plotly-converter\2converter.py", line 128, in
for line in file:
File "C:\Program Files\Python39\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 1588: character maps to

More accurate output recognition (for later refinement)

There are currently only a few extra cases besides poorly graphs, so the code is currently sufficient. Right now I check if "DataFrame" or "Stargazer" appears in the code block to try to determine what the output is supposed to be. But if these functions or objects are used in a later block I won't know what they refer to there. A potential solution is to include a series of try-catch lines to attempt every "to_html" function in every code block. Although it's not very elegant I think it would work. Something to consider in the future to make this more robust. The alternative is to mandate one specific name for the object displayed (eg, star for stargazer, df for data frame, fig for plotly, etc) or a keyword in the block

Streamline interface

I think the tool could save some copy/pasting by taking the following two arguments:

  1. nb_path: Path to the notebook. The program could break this apart into nb_folder and nb_filename, and change the working directory to nb_folder, so that if the notebook uses files based on relative paths, they execute properly.
  2. site_path: Path to the UBICenter/ubicenter.org repo. The folder structure is consistent there, so the program should then write the markdown file and place it into _posts, create the assets/graphs/[nb_filename] folder, and place the resulting plotly html files in that folder.

@yuchida522

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.