Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Export a Pandas dataframe as a table image

from bokeh.io import export_png, export_svgs
from bokeh.models import ColumnDataSource, DataTable, TableColumn

def save_df_as_image(df, path):
    source = ColumnDataSource(df)
    df_columns = [df.index.name]
    df_columns.extend(df.columns.values)
    columns_for_table=[]
    for column in df_columns:
        columns_for_table.append(TableColumn(field=column, title=column))

    data_table = DataTable(source=source, columns=columns_for_table,height_policy="auto",width_policy="auto",index_position=None)
    export_png(data_table, filename = path)
Comment

PREVIOUS NEXT
Code Example
Python :: fstring 
Python :: python ftplib get list of directories 
Python :: change django time zone 
Python :: python remove first element from list 
Python :: plot background color matplotlib 
Python :: python dict key delete 
Python :: pandas max columns 
Python :: how to use csv in python 
Python :: dropout keras 
Python :: operator precedence in python 
Python :: chr() python 
Python :: numpy combinations of 5 bits 
Python :: get root path python 
Python :: pandas change date format to yyyy-mm-dd 
Python :: list comprehension if 
Python :: pandas change order of columns in multiindex 
Python :: how to create model in tensorflow 
Python :: isolate row based on index pandas 
Python :: how to make an ai 
Python :: how to write a while statement in python 
Python :: concat all df in a diction 
Python :: pandas lamda column reference 
Python :: requests.packages.urllib3.util.retry could not be resolved from source 
Python :: how to compile python 
Python :: how to make an infinite loop python 
Python :: load json py 
Python :: numpy convert true false to 0 1 
Python :: how to simplify fraction in python 
Python :: Origin in CORS_ORIGIN_WHITELIST is missing scheme or netloc 
Python :: pandas dataframe froms string 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =