carpentries / feeds.carpentries.org

A repo to generate dynamic JSON data feeds for The Carpentries
https://feeds.carpentries.org
MIT License
3 stars 2 forks source link

add feed and plot for instructor teaching frequency #38

Closed maneesha closed 4 years ago

maneesha commented 4 years ago

Outputs json and png plot of how often our Instructors teach. To do: Add in Redash API keys for query 33 and query 39.

maneesha commented 4 years ago

Do not merge - in progress

maneesha commented 4 years ago

Sample json output:

[{"num_wkshps": 1, "num_instructors": 530}, {"num_wkshps": 2, "num_instructors": 351}, {"num_wkshps": 3, "num_instructors": 170}, {"num_wkshps": 4, "num_instructors": 161}, {"num_wkshps": 5, "num_instructors": 78}, {"num_wkshps": 6, "num_instructors": 107}, {"num_wkshps": 7, "num_instructors": 25}, {"num_wkshps": 8, "num_instructors": 64}, {"num_wkshps": 9, "num_instructors": 16}, {"num_wkshps": 10, "num_instructors": 33}, {"num_wkshps": 11, "num_instructors": 10}, {"num_wkshps": 12, "num_instructors": 27}, {"num_wkshps": 13, "num_instructors": 4}, {"num_wkshps": 14, "num_instructors": 26}, {"num_wkshps": 15, "num_instructors": 4}, {"num_wkshps": 16, "num_instructors": 19}, {"num_wkshps": 17, "num_instructors": 3}, {"num_wkshps": 18, "num_instructors": 15}, {"num_wkshps": 20, "num_instructors": 15}, {"num_wkshps": 21, "num_instructors": 2}, {"num_wkshps": 22, "num_instructors": 6}, {"num_wkshps": 23, "num_instructors": 1}, {"num_wkshps": 24, "num_instructors": 10}, {"num_wkshps": 26, "num_instructors": 6}, {"num_wkshps": 28, "num_instructors": 4}, {"num_wkshps": 30, "num_instructors": 1}, {"num_wkshps": 32, "num_instructors": 6}, {"num_wkshps": 34, "num_instructors": 6}, {"num_wkshps": 36, "num_instructors": 3}, {"num_wkshps": 38, "num_instructors": 4}, {"num_wkshps": 40, "num_instructors": 5}, {"num_wkshps": 42, "num_instructors": 3}, {"num_wkshps": 44, "num_instructors": 2}, {"num_wkshps": 46, "num_instructors": 1}, {"num_wkshps": 48, "num_instructors": 1}, {"num_wkshps": 50, "num_instructors": 4}, {"num_wkshps": 52, "num_instructors": 1}, {"num_wkshps": 54, "num_instructors": 2}, {"num_wkshps": 56, "num_instructors": 1}, {"num_wkshps": 58, "num_instructors": 1}, {"num_wkshps": 62, "num_instructors": 2}, {"num_wkshps": 64, "num_instructors": 1}, {"num_wkshps": 66, "num_instructors": 1}, {"num_wkshps": 70, "num_instructors": 1}, {"num_wkshps": 74, "num_instructors": 1}, {"num_wkshps": 78, "num_instructors": 1}, {"num_wkshps": 80, "num_instructors": 1}, {"num_wkshps": 90, "num_instructors": 1}, {"num_wkshps": 96, "num_instructors": 1}, {"num_wkshps": 112, "num_instructors": 1}, {"num_wkshps": 0, "num_instructors": 1080}]
maneesha commented 4 years ago

Sample plot. Note values in plot are binned to make it more visually appealing. json data includes each value.

image

maneesha commented 4 years ago

Code has been updated, Redash keys are in Travis. Ready for review @fmichonneau

fmichonneau commented 4 years ago

I've pushed a few very minor fixes but it looks good! Could you please make the graph a SVG file instead of a PNG? After that, it will be ready to merge.

fmichonneau commented 4 years ago

there is also this warning:

 Passing a negative integer is deprecated in version 1.0 and will not be supported in future version. Instead, use None to not limit the column width.
  pd.set_option('display.max_colwidth', -1)

(that I also see in other scripts)

maneesha commented 4 years ago

@fmichonneau The warning you spotted is only relevant when displaying a Pandas dataframe. I'll remove it from all scripts in this feed.

I can also make the image be svg rather than png. What is the advantage to using the svg format?

fmichonneau commented 4 years ago

SVG is a vectorized image format which means that it will always look good when it's scaled up or down. See the wikipedia page about vector graphics for more info.

maneesha commented 4 years ago

I've changed the image format from png to svg. For the pd.set_option warning - this is actually only coming from other scripts, not this one. It only matters in development while viewing the dataframe, so I'm submitting a separate PR to address that.