File size: 632 Bytes
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

import streamlit as st


class DataViewer:

    # @st.cache_data
    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),
                file_name=file_name,
                key=key,
                help=help
            )