I am using ipysheets for displaying an interactive sheet in jupyter.
I am following the documentation: https://readthedocs.org/projects/ipysheet/downloads/pdf/latest/
I just can not figure out how to change the layout of a ipysheet once created.
I would like to have a particular width of columns and make possible that the text is wrapped with respect to the content of a particular column (i.e. force line breaks within the cells if the text is too long)
import ipysheet as ip
import pandas as pd
API_link_to_data='https://raw.githubusercontent.com/jenfly/opsd/master/opsd_germany_daily.csv'
energyDF = pd.read_csv(API_link_to_data)
energy_ip = ip.sheet(ip.from_dataframe(energyDF))
energy_ip
When printing out energy_ip (an ipysheet table object) I would like to be able to fix the width (in pixels or how ever) of the columns.
Nevertheless it looks like there is no such property:
ipysheet.easy.column(column,
value,
row_start=0,
row_end=None,
type=None,
color=None,
background_color=None,
font_style=None,
font_weight=None,
style=None,
choice=None,
read_only=False,
numeric_format=’0.000’,
date_format=’YYYY/MM/DD’,
renderer=None, **kwargs)
any idea?
would do the following, hope it answers your question :
import ipysheet as ip
import pandas as pd
import ipywidgets as w
API_link_to_data='https://raw.githubusercontent.com/jenfly/opsd/master/opsd_germany_daily.csv'
energyDF = pd.read_csv(API_link_to_data)
energyDF['comment'] = 'this column will have line breaks'
energy_ip = ip.sheet(ip.from_dataframe(energyDF))
# set column widths
energy_ip.column_width = [10,10,5,5,5,10]
energy_ip.layout = w.Layout(width='500px',height='100%')
for k,c in enumerate(energy_ip.cells):
c.style['textAlign']='center'
c.send_state()
energy_ip