visualizer.pyfile
Browse filesimport plotly.express as px
def create_plot(df, chart_type, x_col, y_col):
if chart_type == "Bar Chart":
fig = px.bar(df, x=x_col, y=y_col)
elif chart_type == "Line Chart":
fig = px.line(df, x=x_col, y=y_col)
elif chart_type == "Scatter Plot":
fig = px.scatter(df, x=x_col, y=y_col)
elif chart_type == "Pie Chart":
fig = px.pie(df, names=x_col, values=y_col)
elif chart_type == "Box Plot":
fig = px.box(df, x=x_col, y=y_col)
else:
raise ValueError("Invalid chart type")
return fig
- data_loader.pyfile +11 -0
data_loader.pyfile
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
|
| 3 |
+
def load_data(file):
|
| 4 |
+
if file.name.endswith('.csv'):
|
| 5 |
+
return pd.read_csv(file.name)
|
| 6 |
+
elif file.name.endswith('.xlsx'):
|
| 7 |
+
return pd.read_excel(file.name)
|
| 8 |
+
elif file.name.endswith('.json'):
|
| 9 |
+
return pd.read_json(file.name)
|
| 10 |
+
else:
|
| 11 |
+
raise ValueError("Unsupported file type")
|