Spaces:
Sleeping
Sleeping
tappyness1
commited on
Commit
β’
d4dc4f4
1
Parent(s):
eb3d6bf
initial
Browse files- app.py +18 -1
- poc.ipynb +84 -0
- token_secret.yaml +1 -0
app.py
CHANGED
@@ -4,7 +4,7 @@ import plotly.express as px
|
|
4 |
from datasets import load_dataset
|
5 |
import os
|
6 |
|
7 |
-
@st.cache()
|
8 |
def bar_chart(counts_df):
|
9 |
fig = px.bar(counts_df, x = 'car', y = 'large_vehicle')
|
10 |
|
@@ -14,6 +14,23 @@ def bar_chart(counts_df):
|
|
14 |
# )
|
15 |
return fig
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
def main():
|
19 |
|
|
|
4 |
from datasets import load_dataset
|
5 |
import os
|
6 |
|
7 |
+
# @st.cache()
|
8 |
def bar_chart(counts_df):
|
9 |
fig = px.bar(counts_df, x = 'car', y = 'large_vehicle')
|
10 |
|
|
|
14 |
# )
|
15 |
return fig
|
16 |
|
17 |
+
def daily_average(counts_df):
|
18 |
+
|
19 |
+
filtered_views_list = ['View_from_Second_Link_at_Tuas_to_sg',
|
20 |
+
'View_from_Second_Link_at_Tuas_to_jh',
|
21 |
+
'View_from_Tuas_Checkpoint_to_sg',
|
22 |
+
'View_from_Tuas_Checkpoint_to_jh',
|
23 |
+
'View_from_Woodlands_Causeway_Towards_Johor_to_sg',
|
24 |
+
'View_from_Woodlands_Causeway_Towards_Johor_to_jh',
|
25 |
+
'View_from_Woodlands_Checkpoint_Towards_BKE_to_sg',
|
26 |
+
'View_from_Woodlands_Checkpoint_Towards_BKE_to_jh']
|
27 |
+
|
28 |
+
counts_df_filter_views = counts_df[counts_df['view'].isin(filtered_views_list)]
|
29 |
+
counts_df_filter_views['date'] = pd.to_datetime(counts_df_filter_views['date'])
|
30 |
+
counts_df_filter_views['day_of_week'] = counts_df_filter_views['date'].dt.day_of_week
|
31 |
+
date_view_group = counts_df_filter_views.groupby(by=['view', 'day_of_week']).mean()
|
32 |
+
date_view_group = date_view_group.reset_index()
|
33 |
+
|
34 |
|
35 |
def main():
|
36 |
|
poc.ipynb
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 4,
|
6 |
+
"metadata": {},
|
7 |
+
"outputs": [
|
8 |
+
{
|
9 |
+
"name": "stderr",
|
10 |
+
"output_type": "stream",
|
11 |
+
"text": [
|
12 |
+
"Using custom data configuration tappyness1--causion-800e18f416d7678b\n",
|
13 |
+
"Found cached dataset parquet (C:/Users/neoce/.cache/huggingface/datasets/tappyness1___parquet/tappyness1--causion-800e18f416d7678b/0.0.0/2a3b91fbd88a2c90d1dbbb32b460cf621d31bd5b05b934492fdef7d8d6f236ec)\n",
|
14 |
+
"100%|ββββββββββ| 1/1 [00:00<00:00, 937.90it/s]\n"
|
15 |
+
]
|
16 |
+
}
|
17 |
+
],
|
18 |
+
"source": [
|
19 |
+
"from datasets import load_dataset\n",
|
20 |
+
"import pandas as pd\n",
|
21 |
+
"import os\n",
|
22 |
+
"import yaml\n",
|
23 |
+
"\n",
|
24 |
+
"token_file = open(\"token_secret.yaml\")\n",
|
25 |
+
"token_obj = yaml.load(token_file, Loader=yaml.FullLoader)\n",
|
26 |
+
"dataset = load_dataset(\"tappyness1/causion\", use_auth_token=token_obj['TOKEN'])\n",
|
27 |
+
"counts_df = pd.DataFrame(dataset['train'])\n"
|
28 |
+
]
|
29 |
+
},
|
30 |
+
{
|
31 |
+
"cell_type": "code",
|
32 |
+
"execution_count": 30,
|
33 |
+
"metadata": {},
|
34 |
+
"outputs": [
|
35 |
+
{
|
36 |
+
"name": "stderr",
|
37 |
+
"output_type": "stream",
|
38 |
+
"text": [
|
39 |
+
"C:\\Users\\neoce\\AppData\\Local\\Temp\\ipykernel_18912\\643665856.py:1: FutureWarning: The default value of numeric_only in DataFrameGroupBy.mean is deprecated. In a future version, numeric_only will default to False. Either specify numeric_only or select only columns which should be valid for the function.\n",
|
40 |
+
" date_view_group = counts_df_filter_views.groupby(by=['view', 'day_of_week']).mean()\n"
|
41 |
+
]
|
42 |
+
}
|
43 |
+
],
|
44 |
+
"source": [
|
45 |
+
"filtered_views_list = ['View_from_Second_Link_at_Tuas_to_sg',\n",
|
46 |
+
" 'View_from_Second_Link_at_Tuas_to_jh',\n",
|
47 |
+
" 'View_from_Tuas_Checkpoint_to_sg',\n",
|
48 |
+
" 'View_from_Tuas_Checkpoint_to_jh',\n",
|
49 |
+
" 'View_from_Woodlands_Causeway_Towards_Johor_to_sg',\n",
|
50 |
+
" 'View_from_Woodlands_Causeway_Towards_Johor_to_jh',\n",
|
51 |
+
" 'View_from_Woodlands_Checkpoint_Towards_BKE_to_sg',\n",
|
52 |
+
" 'View_from_Woodlands_Checkpoint_Towards_BKE_to_jh']\n",
|
53 |
+
"\n",
|
54 |
+
"counts_df_filter_views = counts_df[counts_df['view'].isin(filtered_views_list)]\n",
|
55 |
+
"counts_df_filter_views['date'] = pd.to_datetime(counts_df_filter_views['date'])\n",
|
56 |
+
"counts_df_filter_views['day_of_week'] = counts_df_filter_views['date'].dt.day_of_week\n",
|
57 |
+
"date_view_group = counts_df_filter_views.groupby(by=['view', 'day_of_week']).mean()\n",
|
58 |
+
"date_view_group = date_view_group.reset_index()"
|
59 |
+
]
|
60 |
+
}
|
61 |
+
],
|
62 |
+
"metadata": {
|
63 |
+
"kernelspec": {
|
64 |
+
"display_name": "6242_hw1_q1",
|
65 |
+
"language": "python",
|
66 |
+
"name": "python3"
|
67 |
+
},
|
68 |
+
"language_info": {
|
69 |
+
"codemirror_mode": {
|
70 |
+
"name": "ipython",
|
71 |
+
"version": 3
|
72 |
+
},
|
73 |
+
"file_extension": ".py",
|
74 |
+
"mimetype": "text/x-python",
|
75 |
+
"name": "python",
|
76 |
+
"nbconvert_exporter": "python",
|
77 |
+
"pygments_lexer": "ipython3",
|
78 |
+
"version": "3.8.16"
|
79 |
+
},
|
80 |
+
"orig_nbformat": 4
|
81 |
+
},
|
82 |
+
"nbformat": 4,
|
83 |
+
"nbformat_minor": 2
|
84 |
+
}
|
token_secret.yaml
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
TOKEN: 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
|