Skip to content

Instantly share code, notes, and snippets.

@tianhaoz95
Created November 20, 2021 20:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tianhaoz95/a144a8ef8b610850e310cb13130c2f70 to your computer and use it in GitHub Desktop.
Save tianhaoz95/a144a8ef8b610850e310cb13130c2f70 to your computer and use it in GitHub Desktop.
import pandas as pd
import streamlit as st
def construct_timestamp_index(data: pd.DataFrame) -> pd.DataFrame:
data.index = pd.to_datetime(data['Timestamp (UTC)'],
format='%Y-%m-%d %H:%M:%S')
return data.drop(columns=['Timestamp (UTC)'])
def upload_csv(hint: str) -> pd.DataFrame:
uploaded_file = st.sidebar.file_uploader(label=hint)
if uploaded_file is not None:
return construct_timestamp_index(pd.read_csv(uploaded_file))
return pd.DataFrame()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment