Discovering Data
  • Home
  • Blog
  • become_a_data_scientist
  • Code-examples

Using Pandas and Flask to create a basic web application

5/27/2016

1 Comment

 
The data comes from the University ranking datasets I mentioned in the last post. The CWUR dataset includes the number of patents for each university. I wanted to group the universities by country and sum the total number of patents. The final table should be available via a browser. 

Combining Pandas and Flask makes the task relatively simple. I based my code on the following example. The code:

    
The output can be improved with CSS. But the raw output meets my basic requirements:
Picture
Some notes:

the line of code: df = df.groupby(by=['country'])['patents'].sum().to_frame() is doing most of the work, the groupby() function is simialr to group by in Oracle. This line of code creates a series object, but for the to_html() function to be available I need it to be a dataframe so I used the to_frame() function. The link I provided to the example code above explains how Flask is working.
1 Comment
Abhinav Chaudhary
9/5/2019 07:10:32 am

Do you have the github or the code for 'report.html'

Reply



Leave a Reply.

    This blog includes:

    Scripts mainly in Python with a few in R covering NLP, Pandas, Matplotlib and others. See the home page for links to some of the scripts.  Also includes some explanations of basic data science terminology.

    Archives

    October 2018
    June 2018
    April 2018
    June 2017
    April 2017
    March 2017
    February 2017
    January 2017
    November 2016
    September 2016
    July 2016
    June 2016
    May 2016
    December 2015
    November 2015
    April 2015
    December 2014
    November 2014

    RSS Feed

Proudly powered by Weebly
  • Home
  • Blog
  • become_a_data_scientist
  • Code-examples