-
Notifications
You must be signed in to change notification settings - Fork 4
/
ingestor.py
52 lines (26 loc) · 954 Bytes
/
ingestor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# import necessary libraries
import pandas as pd
import os
import glob
import plotly.express as px
import datetime
# use glob to get all the csv files
# in the folder
path = os.getcwd()
csv_files = glob.glob(os.path.join(path, "*.csv"))
li = []
for filename in csv_files:
df = pd.read_csv(filename, index_col=None, header=0)
li.append(df)
frame = pd.concat(li, axis=0, ignore_index=True)
frame.reset_index()
df_sorted = frame.sort_values(["ANO", "MES", "DIA"])
df_heatmap = df_sorted.groupby(['ANO','DISTRITO','CONCELHO'])[['NCCO']].nunique().reset_index()
#df_heatmap['DATAALERTA']=pd.to_datetime(df['DATAALERTA'])
#print(df_heatmap.info())
df_heatmap.to_csv('heatmap_full.csv')
#events_year = df_sorted.groupby(["DATAALERTA","ANO","DISTRITO"])[["NCCO"]].nunique().reset_index()
#events_year['ANO']=events_year['ANO'].astype(str)
#print(events_year)
#fig = px.bar(events_year,x='ANO',y='NCCO',color='ANO')
#fig.show()