Created
January 23, 2020 15:09
-
-
Save ggodreau/b4614c189d3c7946f187aa9858d6695c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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