tabled.html#
To work with html
Functions
|
Render each dataframe in |
|
Render |
|
Write an entire dataframe to an HTML file with nice formatting. |
|
Render |
|
Get's a list of pandas dataframes from tables scraped from a url. |
|
Get a url_to_html function of a given kind. |
- tabled.html.df_store_to_html(df_store, sep='\n<br>\n')[source]#
Render each dataframe in
df_store, titled by its key’s leading non-digit prefix, joined bysep.A key that is not a string, or has no non-digit prefix (e.g.
0or"2024"), is used whole as the title.
- tabled.html.df_to_html(df, title=None)[source]#
Render
dfas an HTML table, with an optional<h2>title above it.
- tabled.html.dfs_to_html_pretty(dfs, title=None)[source]#
Write an entire dataframe to an HTML file with nice formatting. Thanks to @stackoverflowuser2010 for the pretty printer see https://stackoverflow.com/a/47723330/362951
- tabled.html.dfs_to_pdf_bytes(dfs, title=None)[source]#
Render
dfs(a DataFrame, a mapping, or an iterable of DataFrames) to PDF bytes.Requires the optional
weasyprintdependency.
- tabled.html.get_tables_from_url(url, *, url_to_html='requests', filt=None, encoding='utf-8', **tables_from_html_kwargs)[source]#
Get’s a list of pandas dataframes from tables scraped from a url. Note that this will only work with static pages. If the html needs to be rendered dynamically, you’ll have to get your needed html otherwise (like with selenium).
>>> url = 'https://en.wikipedia.org/wiki/List_of_musical_instruments' >>> tables = get_tables_from_url(url)
If you install selenium and download a chromedriver, you can even use your browser to render dynamic html. Say, to get updated coronavirus stats without a need to figure out the API (I mean, why have to figure out the language of an API, when someone already did that for you in their webpage!!):
url = 'https://www.worldometers.info/coronavirus/?utm_campaign=homeAdvegas1?' tables = get_tables_from_url(url, url_to_html='chrome') # doctest: +SKIP
To make selenium work:
pip install seleniumDownload seleniumdriver here: https://chromedriver.chromium.org/
Uzip and put in a place that’s on you PATH (run command
echo $PATHfor a list of those places)