File size: 708 Bytes
a177196
 
 
f771463
 
 
 
 
 
a177196
f771463
a177196
 
 
f771463
 
 
 
 
 
 
a177196
f771463
 
a177196
f771463
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""
Class for showing header and download button in the same row.
"""

import streamlit as st


class DataViewer:
    def _convert_df_to_csv(self, data, **kwargs):
        return data.to_csv(**kwargs).encode("utf-8")

    def _header_and_download(
        self, header, data, file_name, key=None, label="Download", help="Download data"
    ):
        col1, col2 = st.columns([9, 2])
        with col1:
            st.subheader(header)
        with col2:
            st.write("")
            st.download_button(
                label=label,
                data=self._convert_df_to_csv(data, index=False),
                file_name=file_name,
                key=key,
                help=help,
            )