File size: 2,523 Bytes
d1cc84a
 
 
 
 
 
d4dc4f4
d1cc84a
 
 
 
 
 
 
 
 
d4dc4f4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d1cc84a
 
eb3d6bf
 
d1cc84a
eb3d6bf
d1cc84a
 
eb3d6bf
 
 
d1cc84a
eb3d6bf
d1cc84a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import streamlit as st
import pandas as pd
import plotly.express as px
from datasets import load_dataset
import os

# @st.cache()
def bar_chart(counts_df):
    fig = px.bar(counts_df, x = 'car', y = 'large_vehicle')

    # fig_app_by_arc.update_layout(
    #                             xaxis_title="Name",
    #                             yaxis_title="",
    #                             )
    return fig

def daily_average(counts_df):
    
    filtered_views_list = ['View_from_Second_Link_at_Tuas_to_sg',
                        'View_from_Second_Link_at_Tuas_to_jh',
                        'View_from_Tuas_Checkpoint_to_sg',
                        'View_from_Tuas_Checkpoint_to_jh',
                        'View_from_Woodlands_Causeway_Towards_Johor_to_sg',
                        'View_from_Woodlands_Causeway_Towards_Johor_to_jh',
                        'View_from_Woodlands_Checkpoint_Towards_BKE_to_sg',
                        'View_from_Woodlands_Checkpoint_Towards_BKE_to_jh']

    counts_df_filter_views = counts_df[counts_df['view'].isin(filtered_views_list)]
    counts_df_filter_views['date'] = pd.to_datetime(counts_df_filter_views['date'])
    counts_df_filter_views['day_of_week'] = counts_df_filter_views['date'].dt.day_of_week
    date_view_group = counts_df_filter_views.groupby(by=['view', 'day_of_week']).mean()
    date_view_group = date_view_group.reset_index()


def main():

    # comment out for local testing, but be sure to include after testing
    dataset = load_dataset("tappyness1/causion", use_auth_token=os.environ['TOKEN'])
    # print (dataset)
    # print (pd.DataFrame(dataset['train']))
    counts_df = pd.DataFrame(dataset['train'])

    # only use this part before for local testing
    # once local testing is completed, comment out and use the dataset above
    # counts_df = pd.read_csv("data/counts_dataset.csv")

    # st.set_page_config(layout="wide")
    height = 650

    st.markdown(""" <style>
                #MainMenu {visibility: hidden;}
                footer {visibility: hidden;}
                </style> """, 
                unsafe_allow_html=True
                )

    # Select Plot Option
    st.sidebar.markdown("Checkboxes")
    checkbox_one = st.sidebar.checkbox('Lorem Ip', value = True) # rename as necessary
    checkbox_two = st.sidebar.checkbox('Lorem Ipsum', value = False)

    if checkbox_one:
        st.write("Simple Bar Chart")
        st.plotly_chart(bar_chart(counts_df),use_container_width=True)

if __name__ == "__main__":
    main()