Spaces:
Running
Running
File size: 5,942 Bytes
bdbcb36 369e5bc bdbcb36 369e5bc bdbcb36 369e5bc bdbcb36 369e5bc bdbcb36 369e5bc bdbcb36 |
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
import streamlit as st
import os
import pandas as pd
#import langchain
#from pandasai import SmartDatalake
from pandasai import SmartDataframe
from pandasai.responses.streamlit_response import StreamlitResponse
#from langchain_community.llms import HuggingFacePipeline
#from langchain_community.llms import HuggingFaceEndpoint
#from pathlib import Path
#from transformers import AutoTokenizer
#import transformers
#from pandasai import HuggingFaceEndpoint
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)
#import pandas as pd
df = pd.DataFrame({
"row1": {
"Feb 24": "Februar",
"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"
},
"row2": {
"Feb24": "StandkeSteffen",
"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.": ""
}
}
)
#st.bar_chart(df)
uploaded_file = st.file_uploader("Upload CSV data for analysis", type=['csv'])
#st.title("Datenanalyse mit PandasAI")
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.":""}]
df = pd.DataFrame(data)
if uploaded_file is not None:
df1 = pd.read_csv(uploaded_file)
df1
#st.bar_chart(df)
sdf = SmartDataframe(df1)
#agent = Agent(df)
#result = agent.chat("erstelle balkendiagramm")
#st.write(result)
#sdf.chat("draw chart")
#st.write(sdf.chat("draw chart"))
prompt = st.text_area("Enter your prompt:")
#agent = Agent(df)
#result = agent.chat("erstelle balkendiagramm")
#st.write(result)
#df
#st.write(df)
#st.write(df1)
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))
if st.button("Generate"):
if prompt:
with st.spinner("Generating response..."):
bar = st.progress(0)
sdf = SmartDataframe(df1)
#df
#sdf.chat(prompt)
st.write(sdf.chat(prompt))
#agent = Agent(df1)
#result = agent.chat("erstelle balkendiagramm")
#st.write(result)
#st.write(pandas_ai.run(df1, prompt=prompt))
bar.progress(100)
else:
st.error("Please enter a prompt.")
|