Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,31 +1,25 @@
|
|
1 |
import streamlit as st
|
2 |
import os
|
3 |
import pandas as pd
|
4 |
-
|
5 |
from pandasai import SmartDataframe
|
6 |
from pandasai.responses.streamlit_response import StreamlitResponse
|
7 |
-
|
8 |
#from pandasai import Agent
|
9 |
-
|
10 |
-
|
11 |
|
12 |
os.environ['PANDASAI_API_KEY'] = "$2a$10$2s0v3C29vItNS2CO4QX10OV51/OONFCUNa4e9EU90w2Gozw88f4vK"
|
13 |
|
14 |
st.set_page_config(page_title="SAP Data Analysis", layout="wide")
|
15 |
-
uploaded_files = st.file_uploader("Choose a CSV file", accept_multiple_files=True)
|
16 |
-
for uploaded_file in uploaded_files:
|
17 |
-
bytes_data = uploaded_file.read()
|
18 |
-
st.write("filename:", uploaded_file.name)
|
19 |
-
st.write(bytes_data)
|
20 |
st.image('Pandas-AI-Logo.png', caption=None)
|
21 |
-
#import pandas as pd
|
22 |
uploaded_file = st.file_uploader("Upload CSV data for analysis", type=['csv'])
|
23 |
st.title("Datenanalyse mit PandasAI")
|
24 |
df1 = ""
|
25 |
sdf = ""
|
26 |
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.":""}]
|
27 |
df = pd.DataFrame(data)
|
28 |
-
df
|
29 |
|
30 |
if uploaded_file is not None:
|
31 |
|
@@ -34,8 +28,12 @@ if uploaded_file is not None:
|
|
34 |
df1 = pd.DataFrame(df1)
|
35 |
df1
|
36 |
sdf = SmartDataframe(df1)
|
37 |
-
|
38 |
-
|
|
|
|
|
|
|
|
|
39 |
prompt = st.text_area("Enter your prompt:")
|
40 |
if st.button("Generate"):
|
41 |
|
@@ -44,11 +42,10 @@ if st.button("Generate"):
|
|
44 |
with st.spinner("Generating response..."):
|
45 |
|
46 |
bar = st.progress(0)
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
st.image('./exports/charts/temp_chart.png',caption=None)
|
52 |
#st.write(sdf.chat(prompt))
|
53 |
bar.progress(100)
|
54 |
|
|
|
1 |
import streamlit as st
|
2 |
import os
|
3 |
import pandas as pd
|
4 |
+
from pandasai import SmartDatalake
|
5 |
from pandasai import SmartDataframe
|
6 |
from pandasai.responses.streamlit_response import StreamlitResponse
|
7 |
+
import numpy as np
|
8 |
#from pandasai import Agent
|
9 |
+
import json
|
10 |
+
import matplotlib.pyplot as plt
|
11 |
|
12 |
os.environ['PANDASAI_API_KEY'] = "$2a$10$2s0v3C29vItNS2CO4QX10OV51/OONFCUNa4e9EU90w2Gozw88f4vK"
|
13 |
|
14 |
st.set_page_config(page_title="SAP Data Analysis", layout="wide")
|
|
|
|
|
|
|
|
|
|
|
15 |
st.image('Pandas-AI-Logo.png', caption=None)
|
|
|
16 |
uploaded_file = st.file_uploader("Upload CSV data for analysis", type=['csv'])
|
17 |
st.title("Datenanalyse mit PandasAI")
|
18 |
df1 = ""
|
19 |
sdf = ""
|
20 |
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.":""}]
|
21 |
df = pd.DataFrame(data)
|
22 |
+
#df
|
23 |
|
24 |
if uploaded_file is not None:
|
25 |
|
|
|
28 |
df1 = pd.DataFrame(df1)
|
29 |
df1
|
30 |
sdf = SmartDataframe(df1)
|
31 |
+
bild = st.empty()
|
32 |
+
c = st.container()
|
33 |
+
#with placeholder.container():
|
34 |
+
#st.write("This is one element")
|
35 |
+
#st.write("This is another")
|
36 |
+
|
37 |
prompt = st.text_area("Enter your prompt:")
|
38 |
if st.button("Generate"):
|
39 |
|
|
|
42 |
with st.spinner("Generating response..."):
|
43 |
|
44 |
bar = st.progress(0)
|
45 |
+
bild.empty()
|
46 |
+
c.write(sdf.chat(prompt))
|
47 |
+
if os.path.isfile(./exports/charts/temp_chart.png'):
|
48 |
+
bild.write(st.image('./exports/charts/temp_chart.png',caption=None))
|
|
|
49 |
#st.write(sdf.chat(prompt))
|
50 |
bar.progress(100)
|
51 |
|