qgrid icon indicating copy to clipboard operation
qgrid copied to clipboard

Is it possible to remove the display of row name column?

Open markolopa opened this issue 9 years ago • 6 comments
trafficstars

In other words is there an option such as index=False in df.to_csv(path, index=False)?

Thanks a lot for the wonderful and very useful wrapper! Marko

markolopa avatar Jan 17 '16 14:01 markolopa

Sorry I don't believe there is a way to do this currently. You'll have to remove the column from the DataFrame if you don't want it to appear in the grid. This would be a nice convenience feature to add though, so thanks for filing the issue.

TimShawver avatar Mar 05 '16 21:03 TimShawver

Thanks. Is there a way to remove it from the DataFrame? If I understand correctly the row name qgrid column is not a DataFrame column.

markolopa avatar Mar 06 '16 10:03 markolopa

I may have misunderstood the question. Can you look at the sample notebook here and tell me if either of the examples there have the problem you're talking about? http://nbviewer.jupyter.org/gist/TimShawver/b4bc80d1128407c56c9a

I'm guessing the second example might be what you're talking about, i.e. how a numbered "index" column appears when your DataFrame is lacking an index. You'll notice that the column is also in the default rendering of the DataFrame though, so it's the correct behavior by Qgrid. It's impossible to have a DataFrame without an index, so when you don't specify one yourself, pandas adds one for you.

It might be that the workaround for your specific issue would be to use one of the existing columns in the DataFrame as the index. This stackoverflow article shows how to set the index of your DataFrame to an existing column.

TimShawver avatar Mar 06 '16 15:03 TimShawver

The point is that other dataframe display methods (e.g. to_html()) accept a parameter (index=False) which hides the index column in the resulting html (which you can then render in the notebook using display()). It would be good if qgrid allowed a similar parameter to suppress the index display.

MarkNOakden avatar Mar 20 '18 17:03 MarkNOakden

You can do this: q = qgrid.show_grid(mydf, column_definitions={ 'index': { 'maxWidth': 0, 'minWidth': 0, 'width': 0 } })

I wish this was a qgrid level option do I didn't have all that on my display, but this DOES work.

JohnOmernik avatar Jun 18 '20 21:06 JohnOmernik

q = qgrid.show_grid(mydf, column_definitions={ 'index': { 'maxWidth': 0, 'minWidth': 0, 'width': 0 } })

This still shows a few pixels from the column

shadiakiki1986 avatar Oct 19 '21 14:10 shadiakiki1986