Paginated Dataframe

Hi,
May I ask please, if there is a solution for showing large data frames in a paginated form, e.g. 20 rows at a time, apart from manually implementing this using a slider? I mean something like Jupyter itables: https://github.com/mwouts/itables

Many thanks
Best

1 Like

Hi @aghasemi,

I think thereโ€™s no way to do it apart from manually implementing this using a num_count or slider, I had added this workaround on one of the posts, you might find it helpful.

2 Likes

We also have a GitHub issue for making dataframes better, so keep an eye on this issue:

1 Like

Last but not least, if you feel HTML-adventurous, you could build a static paginated MaterialUI Table by editing this solution on the MaterialUI paginated dataframe example

1 Like

Maybe take a look at https://github.com/datapane/datapane. This application paginates pandas dataframes.

You may use this simple method if you want pagination for a backend pandas dataframe:-

def paginate_dataframe(dataframe, page_size, page_num):

    page_size = page_size

    if page_size is None:

        return None

    offset = page_size*(page_num-1)

    return dataframe[offset:offset + page_size]

check streamlit-aggrid. It has a pagination option.

Check a live example here. Just click Enable Pagination on the sidebar.

2 Likes

Once dataframe is in order, you can take help of Index (which is default in pandas dataframe) and use query function. Following solution is keeping in mind that you are loading large data in dataframe.

#load large data from database ex
query = โ€œselect top 1000000 * from [transaction];โ€
df = pd.read_sql_query(query, connection)
start = (page_number - 1) * page_size
end = start + page_size
#bellow statement will give you back paginated rows.
page = df.query(โ€™(index >= start and index < end )โ€™)
return page