Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -53,18 +53,88 @@ def show_instructions():
|
|
53 |
|
54 |
def data_profiling(uploaded_file):
|
55 |
st.title("Data Profiling App")
|
56 |
-
|
57 |
-
# Load the data
|
58 |
df = pd.read_csv(uploaded_file)
|
59 |
-
|
60 |
-
# Display the dataframe
|
61 |
st.dataframe(df)
|
62 |
-
|
63 |
# Generate and display the data profile report
|
64 |
pr = ProfileReport(df, title="Report")
|
65 |
st_profile_report(pr)
|
66 |
|
67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
if __name__ == "__main__":
|
70 |
main()
|
|
|
53 |
|
54 |
def data_profiling(uploaded_file):
|
55 |
st.title("Data Profiling App")
|
|
|
|
|
56 |
df = pd.read_csv(uploaded_file)
|
|
|
|
|
57 |
st.dataframe(df)
|
|
|
58 |
# Generate and display the data profile report
|
59 |
pr = ProfileReport(df, title="Report")
|
60 |
st_profile_report(pr)
|
61 |
|
62 |
+
def personal_assistant():
|
63 |
+
st.sidebar.title("OpenAI Settings")
|
64 |
+
st.title("Personal Assistant")
|
65 |
+
st.text("A BR CREATION")
|
66 |
+
st.image("chatbot.jpg", caption="Chatbot", width=178)
|
67 |
+
|
68 |
+
uploaded_file = st.file_uploader("Upload CSV file", type=["csv"])
|
69 |
+
if uploaded_file is None:
|
70 |
+
st.warning("Please upload a CSV file.")
|
71 |
+
st.stop() # Stop execution if no file uploaded
|
72 |
+
|
73 |
+
llm = OpenAI(temperature=0)
|
74 |
+
agent = create_csv_agent(
|
75 |
+
llm,
|
76 |
+
uploaded_file,
|
77 |
+
verbose=False,
|
78 |
+
agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
|
79 |
+
)
|
80 |
+
|
81 |
+
predefined_questions = ["How many rows are there in the dataset?", "Explain the dataset."]
|
82 |
+
selected_question = st.selectbox("Select a question", ["Select a question"] + predefined_questions)
|
83 |
+
custom_question = st.text_input("Or ask a custom question")
|
84 |
+
|
85 |
+
if st.button("Ask"):
|
86 |
+
if selected_question != "Select a question":
|
87 |
+
query = selected_question
|
88 |
+
elif custom_question.strip() != "":
|
89 |
+
query = custom_question.strip()
|
90 |
+
else:
|
91 |
+
st.warning("Please select a predefined question or ask a custom question.")
|
92 |
+
return
|
93 |
+
|
94 |
+
start = time.time()
|
95 |
+
answer = agent.run(query)
|
96 |
+
end = time.time()
|
97 |
+
st.write(answer)
|
98 |
+
st.write(f"Answer (took {round(end - start, 2)} s.)")
|
99 |
+
|
100 |
+
def virtual_excel_sheet():
|
101 |
+
st.title("Data Viewer Portal")
|
102 |
+
uploaded_file = st.file_uploader("Upload CSV file", type=["csv"])
|
103 |
+
if uploaded_file is None:
|
104 |
+
st.warning("Please upload a CSV file.")
|
105 |
+
st.stop() # Stop execution if no file uploaded
|
106 |
+
|
107 |
+
df = pd.read_csv(uploaded_file)
|
108 |
+
|
109 |
+
# Convert the dataframe to a list of dictionaries
|
110 |
+
dataframe = df.to_dict(orient="records")
|
111 |
+
|
112 |
+
# Display the dataframe in a Mito spreadsheet
|
113 |
+
final_dfs, code = spreadsheet(dataframe)
|
114 |
+
|
115 |
+
def tableau_ai():
|
116 |
+
st.title("Virtual Tableau AI Tool")
|
117 |
+
init_streamlit_comm()
|
118 |
+
|
119 |
+
# Function to get PygWalker HTML
|
120 |
+
@st.cache_data
|
121 |
+
def get_pyg_html(df: pd.DataFrame) -> str:
|
122 |
+
html = get_streamlit_html(df, use_kernel_calc=True, debug=False)
|
123 |
+
return html
|
124 |
+
|
125 |
+
# Function to get user uploaded DataFrame
|
126 |
+
def get_user_uploaded_data():
|
127 |
+
uploaded_file = st.file_uploader("Upload a CSV file", type=["csv"])
|
128 |
+
if uploaded_file is not None:
|
129 |
+
return pd.read_csv(uploaded_file)
|
130 |
+
return None
|
131 |
+
|
132 |
+
df = get_user_uploaded_data()
|
133 |
+
|
134 |
+
if df is not None:
|
135 |
+
components.html(get_pyg_html(df), width=1300, height=1000, scrolling=True)
|
136 |
+
else:
|
137 |
+
st.write("Please upload a CSV file to proceed.")
|
138 |
|
139 |
if __name__ == "__main__":
|
140 |
main()
|