sarim commited on
Commit
ca75418
·
1 Parent(s): f1a296a

add docker and py file

Browse files
Files changed (3) hide show
  1. 1711709179672.csv +0 -0
  2. Dockerfile +14 -0
  3. main.py +116 -0
1711709179672.csv ADDED
The diff for this file is too large to render. See raw diff
 
Dockerfile ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
2
+ # you will also find guides on how best to write your Dockerfile
3
+
4
+ FROM python:3.9
5
+
6
+ WORKDIR /code
7
+
8
+ COPY ./requirements.txt /code/requirements.txt
9
+
10
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
11
+
12
+ COPY . .
13
+
14
+ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
main.py ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from logging import log
2
+ from dash import Dash, html, dcc, callback, Output, Input
3
+ import pandas as pd
4
+ import plotly.express as px
5
+ from plotly.graph_objs import scatter
6
+ import plotly.graph_objects as go
7
+ df = pd.read_csv('1711709179672.csv',na_values="None")
8
+
9
+ df.insert(4,"Size",(10 * df["Amount"].abs())/100)
10
+
11
+ df['Departments'].fillna("no departments",inplace=True)
12
+
13
+
14
+
15
+
16
+ app = Dash(__name__)
17
+
18
+
19
+ app.layout = html.Div(children = [
20
+ html.Div(
21
+ className="row",
22
+ children=[
23
+ html.Div(
24
+ className="four columns div-user-controls",
25
+ children=[
26
+ html.H2("XPENCE-INSIGHT"),
27
+ html.H3("""Visualising Xpence transaction"""),
28
+ html.H4("""Pick one User from the dropdown below."""),
29
+ ],
30
+ ),
31
+ html.Div(
32
+
33
+ className="eight columns div-for-charts bg-grey",
34
+
35
+ children=[
36
+ dcc.Dropdown(
37
+ df['Card holder'].unique(),
38
+ 'Radu Pertescu',
39
+ id='xaxis-column',
40
+ placeholder= "Radu Pertescu",
41
+
42
+ ),
43
+ dcc.Graph(id="scatterGraph",animate=True),
44
+ dcc.Graph(id='barGraph'),
45
+ dcc.Graph(id='areaGraph'),
46
+ dcc.Graph(id='histogramGraph')
47
+ ]
48
+ ),
49
+ ]
50
+ ),
51
+
52
+ #dcc.Graph(figure=px.scatter(df,x="Transaction Date", y="Amount")),
53
+
54
+ ##dcc.Graph(figure=px.funnel(df,x='Amount',y='Category'))
55
+ #dcc.Graph(figure=px.scatter(df,x="Amount", y="Transaction Date",color="Card holder")),
56
+ # dcc.Graph(figure=px.icicle(df,path=[px.Constant("all"), 'Approval Status', 'Card holder','Category'],color='Category',color_continuous_scale='RdBu')),
57
+
58
+ # dcc.Graph(figure=px.sunburst(df,path=["Transaction Type","Card holder","Approval Status"],color='Amount')),
59
+ # dcc.Graph(figure=px.parallel_categories(df,dimensions=["Card holder","Category","Branches","Departments","Approval Status","Receipt"],color="Amount")),
60
+ # dcc.Graph(figure=px.scatter(df,x="Amount", y="Merchant",color="Card holder",opacity=0.7)),
61
+
62
+
63
+
64
+ ])
65
+
66
+
67
+ @callback(
68
+ Output("scatterGraph","figure"),
69
+ Input("xaxis-column","value")
70
+
71
+ )
72
+ def update_graph(userName):
73
+ filtered_df = df[df["Card holder"] == userName]
74
+ fig = px.scatter(filtered_df,x="Amount", y="Transaction Date",color="Transaction Type",title="Transaction type and amount based on date")
75
+
76
+ return fig
77
+
78
+
79
+ @callback(
80
+ Output("barGraph","figure"),
81
+ Input("xaxis-column","value")
82
+ )
83
+ def update_bar_graph(userName):
84
+ filtered_df = df[df["Card holder"] == userName]
85
+ count_data_frame = filtered_df
86
+ count_data_frame = filtered_df.groupby('Category').count().reset_index()
87
+ fig = px.bar(count_data_frame,x="Category", y="Amount",color='Category',title="Category count")
88
+ return fig
89
+
90
+ @callback(
91
+ Output("areaGraph","figure"),
92
+ Input("xaxis-column","value")
93
+ )
94
+ def update_area_graph(userName):
95
+ filtered_df = df[df["Card holder"] == userName]
96
+ filtered_df['Transaction Date'] = pd.to_datetime(filtered_df['Transaction Date'],format='%d/%m/%Y %H:%M')
97
+ filtered_df['Transaction Date'] = filtered_df['Transaction Date'].dt.round('D')
98
+ filtered_df['Transaction Date'].dt.strftime("%Y-%m-%d")
99
+ transaction_data_frame = filtered_df
100
+ transaction_data_frame = filtered_df.groupby('Transaction Date').count().reset_index()
101
+ fig = px.area(transaction_data_frame,x='Transaction Date',y='Amount',markers=True,title="Number of transaction on a single day")
102
+ return fig
103
+
104
+
105
+ @callback(
106
+ Output("histogramGraph","figure"),
107
+ Input("xaxis-column","value")
108
+ )
109
+ def update_histogram_graph(userName):
110
+ filtered_df = df[df["Card holder"] == userName]
111
+ fig=px.histogram(filtered_df,x='Approval Status',color="Approval Status",title="Approval status count")
112
+ return fig
113
+
114
+
115
+ if __name__ == '__main__':
116
+ app.run(port='8051',debug=True)