Pranav0111 commited on
Commit
6a37941
·
verified ·
1 Parent(s): 7f7feff

Delete data_processor.py

Browse files
Files changed (1) hide show
  1. data_processor.py +0 -62
data_processor.py DELETED
@@ -1,62 +0,0 @@
1
- import pandas as pd
2
- import numpy as np
3
- import plotly.express as px
4
- import plotly.graph_objects as go
5
- import streamlit as st
6
- from typing import Dict, List, Any
7
-
8
-
9
- class DataProcessor:
10
- def __init__(self):
11
- self.data = None
12
- self.numeric_columns = []
13
- self.categorical_columns = []
14
- self.date_columns = []
15
-
16
- def load_data(self, file) -> bool:
17
- try:
18
- self.data = pd.read_csv(file)
19
- self._classify_columns()
20
- return True
21
- except Exception as e:
22
- st.error(f"Error loading data: {str(e)}")
23
- return False
24
-
25
- def _classify_columns(self):
26
- for col in self.data.columns:
27
- if pd.api.types.is_numeric_dtype(self.data[col]):
28
- self.numeric_columns.append(col)
29
- elif pd.api.types.is_datetime64_any_dtype(self.data[col]):
30
- self.date_columns.append(col)
31
- else:
32
- try:
33
- pd.to_datetime(self.data[col])
34
- self.date_columns.append(col)
35
- except:
36
- self.categorical_columns.append(col)
37
-
38
- def get_basic_stats(self) -> Dict[str, Any]:
39
- if self.data is None:
40
- return {}
41
-
42
- stats = {
43
- 'summary': self.data[self.numeric_columns].describe(),
44
- 'missing_values': self.data.isnull().sum(),
45
- 'row_count': len(self.data),
46
- 'column_count': len(self.data.columns)
47
- }
48
- return stats
49
-
50
- def create_visualization(self, chart_type: str, x_col: str, y_col: str, color_col: str = None) -> go.Figure:
51
- if chart_type == "Line Plot":
52
- fig = px.line(self.data, x=x_col, y=y_col, color=color_col)
53
- elif chart_type == "Bar Plot":
54
- fig = px.bar(self.data, x=x_col, y=y_col, color=color_col)
55
- elif chart_type == "Scatter Plot":
56
- fig = px.scatter(self.data, x=x_col, y=y_col, color=color_col)
57
- elif chart_type == "Box Plot":
58
- fig = px.box(self.data, x=x_col, y=y_col, color=color_col)
59
- else:
60
- fig = px.histogram(self.data, x=x_col, color=color_col)
61
-
62
- return fig