Skip to content

Instantly share code, notes, and snippets.

@ggodreau
Created January 23, 2020 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ggodreau/b4614c189d3c7946f187aa9858d6695c to your computer and use it in GitHub Desktop.
Save ggodreau/b4614c189d3c7946f187aa9858d6695c to your computer and use it in GitHub Desktop.
import pandas as pd
df1 = pd.DataFrame({
'a': [1,2,3],
'b': [4,5,6]
})
df2 = pd.DataFrame({
'c': [7,8],
'd': [9,10],
'e': [11,12]
})
# concatenating strings example with the + operator
my_form = '''<form action="/action_page.php">
First name:<br>
<input type="text" name="firstname" value="Mickey">
<br>
Last name:<br>
<input type="text" name="lastname" value="Mouse">
<br><br>
<input type="submit" value="Submit">
</form>'''
df1.to_html() + df2.to_html() + my_form
# using f strings to do the same ting
my_srt = f'''
<html>
<head>Helo world!</head>
{df1.to_html()}
<form action="/action_page.php">
First name:<br>
<input type="text" name="firstname" value="Mickey">
<br>
Last name:<br>
<input type="text" name="lastname" value="Mouse">
<br><br>
<input type="submit" value="Submit">
</form>
</html>
'''
# you might need to wrap the final output string with make_response
return make_response(my_srt, ...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment