Add Options to display DataFrame Index
sinhrks opened this issue · comments
Thanks for the great package!
Currently, spyre
doesn't render DataFrame
index by default. Is it reasonable to add an option to switch the behaviour?
Also, there is a bug when a DataFrame
has a named Index
. Pls see the below image which has unnecessary row.
from spyre import server
import numpy as np
import pandas as pd
idx = pd.Index(list('ABCDE'), name='index')
df = pd.DataFrame(np.random.randn(5, 5), index=idx)
class Example(server.App):
tabs = ['example']
outputs = [{"output_type" : "table",
"output_id" : "table_id",
"tab" : "example",
"on_page_load" : True }]
def getData(self, params):
return df
app = Example()
app.launch(port=9093)
Sorry, I found the latter bug is caused by pandas.DataFrame.to_html()
side. I've issued pandas-dev/pandas#10344.
What I would like to ask you in this issue is whether adding an option to draw Index
is reasonable because Index
can contain meaningful information such as datetime
.
@sinhrks couldn't you just call the .reset_index() method on the dataframe?
Possible as a workaround, but DataFrame.index
often contain important information. I think it is better to always display index
if there is no switching option.