Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -60,7 +60,7 @@ def preprocess_dataframe(df):
|
|
| 60 |
return None
|
| 61 |
|
| 62 |
# Analysis Function
|
| 63 |
-
def analyze_data(data, visualization_type
|
| 64 |
st.subheader("Basic Analysis")
|
| 65 |
st.write("Shape of Data:", data.shape)
|
| 66 |
st.write("Data Types:")
|
|
@@ -80,11 +80,7 @@ def analyze_data(data, visualization_type, class_size=10):
|
|
| 80 |
ax.set_ylabel(y_col)
|
| 81 |
st.pyplot(fig)
|
| 82 |
# Visualization logic
|
| 83 |
-
|
| 84 |
-
st.subheader("Correlation Heatmap")
|
| 85 |
-
fig, ax = plt.subplots(figsize=(8, 6))
|
| 86 |
-
sns.heatmap(numeric_data.corr(), annot=True, ax=ax, cmap="coolwarm", fmt=".2f")
|
| 87 |
-
st.pyplot(fig)
|
| 88 |
|
| 89 |
|
| 90 |
|
|
@@ -115,11 +111,11 @@ def analyze_data(data, visualization_type, class_size=10):
|
|
| 115 |
st.warning("No valid visualization option selected or data available.")
|
| 116 |
|
| 117 |
# Automatically generate a prompt for Groq based on the analysis
|
| 118 |
-
prompt = generate_groq_prompt(data, visualization_type
|
| 119 |
return prompt
|
| 120 |
|
| 121 |
# Function to generate a prompt based on the data analysis
|
| 122 |
-
def generate_groq_prompt(data, visualization_type
|
| 123 |
# Convert DataFrame to a string without the index
|
| 124 |
data_without_index = data.to_string(index=False)
|
| 125 |
|
|
@@ -127,7 +123,7 @@ def generate_groq_prompt(data, visualization_type, class_size):
|
|
| 127 |
Here is the summary statistics for the dataset:
|
| 128 |
{data_without_index}
|
| 129 |
|
| 130 |
-
The user has selected the '{visualization_type}' visualization type
|
| 131 |
Please generate Python code that does this and for any data, please don't use any file input. Write the data in the code.
|
| 132 |
"""
|
| 133 |
|
|
@@ -150,15 +146,15 @@ if uploaded_file is not None:
|
|
| 150 |
# Visualization Selection
|
| 151 |
visualization_type = st.selectbox(
|
| 152 |
"Select a visualization type:",
|
| 153 |
-
[
|
| 154 |
)
|
| 155 |
|
| 156 |
# User input for class size customization
|
| 157 |
-
|
| 158 |
|
| 159 |
# Perform Analysis and Visualization
|
| 160 |
-
prompt = analyze_data(data, visualization_type
|
| 161 |
-
|
| 162 |
|
| 163 |
# Chat with Groq Section
|
| 164 |
st.subheader("Chat with Groq")
|
|
|
|
| 60 |
return None
|
| 61 |
|
| 62 |
# Analysis Function
|
| 63 |
+
def analyze_data(data, visualization_type):
|
| 64 |
st.subheader("Basic Analysis")
|
| 65 |
st.write("Shape of Data:", data.shape)
|
| 66 |
st.write("Data Types:")
|
|
|
|
| 80 |
ax.set_ylabel(y_col)
|
| 81 |
st.pyplot(fig)
|
| 82 |
# Visualization logic
|
| 83 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
|
| 86 |
|
|
|
|
| 111 |
st.warning("No valid visualization option selected or data available.")
|
| 112 |
|
| 113 |
# Automatically generate a prompt for Groq based on the analysis
|
| 114 |
+
prompt = generate_groq_prompt(data, visualization_type)
|
| 115 |
return prompt
|
| 116 |
|
| 117 |
# Function to generate a prompt based on the data analysis
|
| 118 |
+
def generate_groq_prompt(data, visualization_type):
|
| 119 |
# Convert DataFrame to a string without the index
|
| 120 |
data_without_index = data.to_string(index=False)
|
| 121 |
|
|
|
|
| 123 |
Here is the summary statistics for the dataset:
|
| 124 |
{data_without_index}
|
| 125 |
|
| 126 |
+
The user has selected the '{visualization_type}' visualization type .
|
| 127 |
Please generate Python code that does this and for any data, please don't use any file input. Write the data in the code.
|
| 128 |
"""
|
| 129 |
|
|
|
|
| 146 |
# Visualization Selection
|
| 147 |
visualization_type = st.selectbox(
|
| 148 |
"Select a visualization type:",
|
| 149 |
+
[ "Bar Chart", "Line Graph", "Area Chart"]
|
| 150 |
)
|
| 151 |
|
| 152 |
# User input for class size customization
|
| 153 |
+
|
| 154 |
|
| 155 |
# Perform Analysis and Visualization
|
| 156 |
+
prompt = analyze_data(data, visualization_type)
|
| 157 |
+
|
| 158 |
|
| 159 |
# Chat with Groq Section
|
| 160 |
st.subheader("Chat with Groq")
|