Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to show a table with both head and tail? #218

Open
Norlandz opened this issue Jan 27, 2024 · 4 comments
Open

How to show a table with both head and tail? #218

Norlandz opened this issue Jan 27, 2024 · 4 comments

Comments

@Norlandz
Copy link

ie:
Is there a config such that:
instead of df.head(5).append(df.tail(5)),
just df, and both head and tail are shown (with ... in middle)?

@mwouts
Copy link
Owner

mwouts commented Jan 27, 2024

Hello @Norlandz , that's a very interesting question, and I would have use of that myself.

It is currently not possible to do so. However seeing https://datatables.net/forums/discussion/60989/fixed-first-row, I have experimented a bit with table.header and table.footer and was able to get this, with one fixed row on the top, one fixed row at the bottom, and the whole the table in between (which you can scroll):

image

Would that work for you? (with maybe a few more fixed rows at the top/bottom, and no row duplication)

For reference the code for that experiment is available at https://live.datatables.net/qujunigu/856/edit

@Norlandz
Copy link
Author

If this is the current workaround, I may try with it.

But if you think this is not worth the time to implement it, its fine for me too.

--
Can it display 5 tail rows in footer?

--
Is there an api for writing those js in ipynb?

--
To solve this, wouldnt there be a way that:
you can sort the index in a way that
shows 1,2,3,97,98,99
instead of 1,2,3,4,5,6

(--ie: in the code, for the comparator, give a higher priority for the last indexes 97,98,99)

--
(Thanks for your reply!)

@mwouts
Copy link
Owner

mwouts commented Jan 28, 2024

Oh it's not even a workaround - just a preview of how a future feature could look like.

Sure it would make sense to be able to fix multiple rows both in the header and footer. Would two options like fixed_first_rows and fixed_last_rows, or even just fixed_rows (type int, default to 0) fit your use case ? I don't think I would like to support arbitrary fixed rows indices, since the fixed rows will be always displayed at the top or bottom of the datatables, and I prefer to preserve the ordering of the input dataframe.

@Norlandz
Copy link
Author

@mwouts

Oh it's not even a workaround

(To me, it feels a workaround.)

fixed_first_rows and fixed_last_rows

Sounds good for me.

(Thanks for the reply!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants