schichtplan / app.py
mgokg's picture
Update app.py
3a2ad41 verified
raw
history blame
4.61 kB
import streamlit as st
import os
import pandas as pd
from pandasai import SmartDatalake
from pandasai import SmartDataframe
from pandasai.responses.streamlit_response import StreamlitResponse
import numpy as np
#from pandasai import Agent
import json
import matplotlib.pyplot as plt
os.environ['PANDASAI_API_KEY'] = "$2a$10$2s0v3C29vItNS2CO4QX10OV51/OONFCUNa4e9EU90w2Gozw88f4vK"
st.set_page_config(page_title="SAP Data Analysis", layout="wide")
st.image('Pandas-AI-Logo.png', caption=None)
uploaded_file = st.file_uploader("Upload CSV data for analysis", type=['csv'])
df1 = ""
sdf = ""
data = [{"Feb 24":"","1.":"Do","2.":"Fr","3.":"Sa","4.":"So","5.":"Mo","6.":"Di","7.":"Mi","8.":"Do","9.":"Fr","10.":"Sa","11.":"So","12.":"Mo","13.":"Di","14.":"Mi","15.":"Do","16.":"Fr","17.":"Sa","18.":"So","19.":"Mo","20.":"Di","21.":"Mi","22.":"Do","23.":"Fr","24.":"Sa","25.":"So","26.":"Mo","27.":"Di","28.":"Mi","29.":"Do"},{"Feb 24":"Standke Steffen","1.":"F","2.":"F","3.":"","4.":"","5.":"","6.":"","7.":"","8.":"","9.":"","10.":"","11.":"","12.":"","13.":"","14.":"UA","15.":"UA","16.":"","17.":"SD","18.":"SD","19.":"","20.":"","21.":"","22.":"","23.":"","24.":"","25.":"","26.":"","27.":"","28.":"","29.":""},{"Feb 24":"Will Susanne","1.":"","2.":"TZ","3.":"","4.":"","5.":"UA","6.":"","7.":"","8.":"","9.":"TZ","10.":"","11.":"","12.":"","13.":"","14.":"","15.":"","16.":"TZ","17.":"","18.":"","19.":"","20.":"","21.":"","22.":"","23.":"TZ","24.":"","25.":"","26.":"","27.":"","28.":"","29.":""},{"Feb 24":"Raab Julia","1.":"TZ","2.":"TZ","3.":"","4.":"","5.":"","6.":"","7.":"","8.":"TZ","9.":"TZ","10.":"BLOCKER","11.":"","12.":"Ü","13.":"Ü","14.":"Ü","15.":"TZ","16.":"TZ","17.":"BLOCKER","18.":"","19.":"","20.":"","21.":"","22.":"TZ","23.":"TZ","24.":"","25.":"SD","26.":"","27.":"","28.":"","29.":"TZ"},{"Feb 24":"Eckert Marion","1.":"","2.":"","3.":"","4.":"","5.":"","6.":"","7.":"","8.":"","9.":"Ü","10.":"","11.":"","12.":"S","13.":"S","14.":"S","15.":"S","16.":"S","17.":"","18.":"","19.":"","20.":"","21.":"","22.":"","23.":"","24.":"","25.":"","26.":"S","27.":"S","28.":"S","29.":"S"},{"Feb 24":"Meder, Milena","1.":"","2.":"","3.":"","4.":"","5.":"","6.":"","7.":"","8.":"","9.":"","10.":"","11.":"","12.":"F","13.":"F","14.":"","15.":"F","16.":"F","17.":"","18.":"","19.":"","20.":"","21.":"","22.":"","23.":"","24.":"","25.":"","26.":"Voloreise","27.":"","28.":"","29.":""},{"Feb 24":"Despang Angelika","1.":"","2.":"","3.":"SD","4.":"","5.":"","6.":"","7.":"","8.":"","9.":"","10.":"","11.":"","12.":"UA","13.":"UA","14.":"UA","15.":"","16.":"","17.":"","18.":"","19.":"F","20.":"F","21.":"F","22.":"F","23.":"F","24.":"","25.":"","26.":"","27.":"","28.":"","29.":""},{"Feb 24":"Heike Beudert","1.":"TZ","2.":"0,5 U","3.":"","4.":"","5.":"TZ","6.":"","7.":"","8.":"","9.":"","10.":"SD","11.":"SD","12.":"UA","13.":"UA","14.":"TZ","15.":"TZ","16.":"TZ","17.":"","18.":"","19.":"TZ","20.":"TZ","21.":"TZ","22.":"TZ","23.":"TZ","24.":"","25.":"","26.":"F","27.":"F","28.":"F","29.":"F"},{"Feb 24":"Borst Benedikt","1.":"","2.":"","3.":"","4.":"SD","5.":"F","6.":"F","7.":"F","8.":"F","9.":"F","10.":"BLOCKER","11.":"","12.":"UA","13.":"UA","14.":"F","15.":"","16.":"","17.":"","18.":"","19.":"","20.":"","21.":"","22.":"","23.":"","24.":"BLOCKER","25.":"","26.":"","27.":"","28.":"","29.":""}]
df1 = pd.DataFrame(data)
#df
if uploaded_file is not None:
df1 = pd.read_csv(uploaded_file)
#st.table(df1)
df1 = pd.DataFrame(df1)
df1
sdf = SmartDataframe(df1)
bild = st.empty()
c = st.container()
c.text("Datenanalyse & Datenvisualisierung")
#with placeholder.container():
#st.write("This is one element")
#st.write("This is another")
prompt = st.text_area("Enter your prompt:")
if st.button("Generate"):
if prompt:
with st.spinner("Generating response..."):
bar = st.progress(0)
#c.write(bar)
#c.write(st.spinner)
bild.empty()
bild.write(sdf.chat(prompt))
if os.path.isfile('./exports/charts/temp_chart.png'):
bild.write(st.image('./exports/charts/temp_chart.png',caption=None))
#st.write(sdf.chat(prompt))
bar.progress(100)
else:
st.error("Please enter a prompt.")
#agent = Agent(df)
#result = agent.chat("erstelle balkendiagramm")
#st.write(result)
#sdf = SmartDataframe(df)
#sdf.chat("draw chart")
#pandas_ai = PandasAI(llm, verbose=True, save_charts=True)
#st.write(sdf.chat("Plot a chart"))
#st.write(st.bar_chart(data))