charting / app.py
JUNGU's picture
Create app.py
bd820cc
raw
history blame
1.4 kB
import streamlit as st
import pandas as pd
import matplotlib.pyplot as plt
# ํŒŒ์ผ ์—…๋กœ๋“œ
uploaded_file = st.file_uploader("Choose a CSV file", type="csv")
# ๋ฐ์ดํ„ฐ ํƒ€์ž„ ํ”„๋ ˆ์ž„ ์„ ํƒ
time_frame_options = ["1๋ถ„", "5๋ถ„", "10๋ถ„", "30๋ถ„", "60๋ถ„"]
time_frame = st.selectbox("๋ฐ์ดํ„ฐ ํƒ€์ž„ ํ”„๋ ˆ์ž„ ์„ ํƒ:", time_frame_options)
time_frame_map = {"1๋ถ„": 1, "5๋ถ„": 5, "10๋ถ„": 10, "30๋ถ„": 30, "60๋ถ„": 60}
time_frame_minutes = time_frame_map[time_frame]
if uploaded_file:
# CSV ํŒŒ์ผ ์ฝ๊ธฐ
df = pd.read_csv(uploaded_file)
# timestamp๋ฅผ datetime ํ˜•ํƒœ๋กœ ๋ณ€ํ™˜
df['timestamp'] = pd.to_datetime(df['timestamp'], unit='ms')
# ์„ ํƒ๋œ ํƒ€์ž„ ํ”„๋ ˆ์ž„์œผ๋กœ ๋ฆฌ์ƒ˜ํ”Œ๋ง
df_resampled = df.resample(f'{time_frame_minutes}T', on='timestamp').mean()
# RGB ๊ทธ๋ž˜ํ”„
plt.figure(figsize=(15, 5))
plt.plot(df_resampled['R'], label='R')
plt.plot(df_resampled['G'], label='G')
plt.plot(df_resampled['B'], label='B')
plt.title('RGB Color Variation')
plt.xlabel('Time')
plt.ylabel('Value')
plt.legend()
st.pyplot()
# HSV ๊ทธ๋ž˜ํ”„
plt.figure(figsize=(15, 5))
plt.plot(df_resampled['H'], label='H')
plt.plot(df_resampled['S'], label='S')
plt.plot(df_resampled['V'], label='V')
plt.title('HSV Color Variation')
plt.xlabel('Time')
plt.ylabel('Value')
plt.legend()
st.pyplot()