File size: 1,050 Bytes
6020fd9
 
 
 
949e47b
de9d51f
6020fd9
de9d51f
6020fd9
de9d51f
6020fd9
de9d51f
6020fd9
 
de9d51f
6020fd9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import pandas as pd
import numpy as np
from datetime import datetime, timedelta
from io import StringIO

st.title('Cumulative Trend')

uploaded_file = st.file_uploader("Choose a csv file including 'date' column.")

if uploaded_file is not None:

  df = pd.read_csv(uploaded_file, sep=",", usecols=["date"])
  df = df.dropna(axis=0)

  date_list = pd.to_datetime(df.squeeze()).dt.date.tolist()
  date_list.sort()
    
  start_date = date_list[0]
  end_date = date_list[-1]
  day_count = (end_date - start_date).days + 1

  x = np.arange(start_date, end_date + timedelta(days=1), timedelta(days=1)).astype(datetime)
  y = np.zeros(day_count)

  for d in date_list:
      y[(d - start_date).days] += 1

  y_count = np.cumsum(y)

  df = pd.DataFrame({'date': x, 'count': y_count})

  st.area_chart(df.set_index('date'))

  col1, col2 = st.columns(2)
  col1.metric("rows", len(date_list))
  col2.metric("days", day_count)

  col3, col4 = st.columns(2)
  col3.metric("start", str(start_date))
  col4.metric("end", str(end_date))