-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmegye.py
More file actions
63 lines (49 loc) · 1.4 KB
/
megye.py
File metadata and controls
63 lines (49 loc) · 1.4 KB
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
53
54
55
56
57
58
59
60
61
62
63
# pip install numpy pandas plotly lxml
import json
import pandas as pd
from urllib.request import urlopen
import plotly.graph_objects as go
geojson_url = '''
https://raw.githubusercontent.com/skylite21/csv_for_colab/master/megyek_uj.json
'''
data = pd.read_html(
'https://en.wikipedia.org/wiki/COVID-19_pandemic_in_Hungary'
)
datum = '2021.05.16.'
# print(data)
megye_adatok = data[4]
megye_adatok.columns = megye_adatok.columns.droplevel(-1)
# print(megye_adatok)
megye_adatok = megye_adatok.dropna()
megye_adatok = megye_adatok.drop(['all', 'Hospitalized', 'Ventilated'], axis=1)
df = megye_adatok.loc[megye_adatok['Date'] == datum]
df = df.transpose()
df.reset_index(inplace=True)
df.columns = ['megye', 'covid']
df = df[1:]
df['megye'] = df['megye'].astype(str) + ' megye'
df['megye'][5] = 'Csongrád megye'
df['megye'][20] = 'Budapest'
# print(df)
with urlopen(geojson_url) as response:
megyek = json.load(response)
data = dict(
type='choroplethmapbox',
locations=df['megye'],
z=df['covid'],
colorscale='Rainbow',
geojson=megyek,
hoverlabel={'namelength': -1},
featureidkey='properties.name',
marker={'line': {'width': 2}, 'opacity': 0.5}
)
layout = dict(
mapbox=dict(
style='carto-positron',
center={'lon': 19.30, 'lat': 47.30},
zoom=6
),
margin={'l': 0, 'r': 0, 'b': 0, 't': 0}
)
fig = go.Figure(data=data, layout=layout)
fig.show()