flask pandas code example
Example 1: python flask
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return "Hello world!"
if __name__ == '__main__':
app.debug = True
app.run()
Example 2: flask pandas dataframe to html table pdf
from flask import *
import pandas as pd
app = Flask(__name__)
@app.route("/tables")
def show_tables():
data = pd.read_excel('dummy_data.xlsx')
data.set_index(['Name'], inplace=True)
data.index.name=None
females = data.loc[data.Gender=='f']
males = data.loc[data.Gender=='m']
return render_template('view.html',tables=[females.to_html(classes='female'), males.to_html(classes='male')],
titles = ['na', 'Female surfers', 'Male surfers'])
if __name__ == "__main__":
app.run(debug=True)