Migrating the plot_world2 method to the new Plotty API
This commit is contained in:
parent
8240fa35a5
commit
12c89a87eb
4 changed files with 39 additions and 9 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -1,6 +1,7 @@
|
|||
*.csv
|
||||
*.html
|
||||
*.cfg
|
||||
*.svg
|
||||
__pycache__
|
||||
.vscode/
|
||||
myconfig.cfg
|
||||
myconfig.cfg
|
||||
|
|
|
|||
21
fedora_all_example.py
Executable file
21
fedora_all_example.py
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
#!/usr/bin/env python3
|
||||
# A simple test
|
||||
# Alberto Rodriguez Sanchez bt0dotninja@fedoraproject.org
|
||||
# Renato Silva resilva87@fedoraproject.org
|
||||
|
||||
|
||||
|
||||
import pandas
|
||||
from geofp import geofp
|
||||
from datetime import datetime, timezone
|
||||
|
||||
if __name__=='__main__':
|
||||
#constructor load the config file (Mandatory)
|
||||
gp=geofp('myconfig.cfg')
|
||||
# get all the members active since June, 01
|
||||
mydate=datetime(2020,1,1,tzinfo=timezone.utc)
|
||||
print(mydate)
|
||||
df=gp.all_fedorians(mydate)
|
||||
# save as csv (actually is pandas dataframe)
|
||||
df.to_csv('Fedora_Community.csv')
|
||||
print(gp.plot_world2(title='Fedora Community',label='Active members by country',filename='Fedora_Community.html', notebook=False))
|
||||
|
|
@ -7,12 +7,15 @@
|
|||
|
||||
import pandas
|
||||
from geofp import geofp
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timezone
|
||||
|
||||
if __name__=='__main__':
|
||||
#constructor load the config file (Mandatory)
|
||||
gp=geofp('myconfig.cfg')
|
||||
# get all the members active since June, 01
|
||||
df=gp.by_group('fedora-join',datetime(2018,7,1))
|
||||
mydate=datetime(2020,1,1,tzinfo=timezone.utc)
|
||||
print(mydate)
|
||||
df=gp.by_group('fedora-join',mydate)
|
||||
# save as csv (actually is pandas dataframe)
|
||||
df.to_csv('Fedora_join.csv')
|
||||
print(gp.plot_world2(title='Fedora Join Team',label='Members by country',filename='Fedora Join.html', notebook=False))
|
||||
|
|
|
|||
17
geofp.py
17
geofp.py
|
|
@ -62,7 +62,7 @@ class geofp(object):
|
|||
return self.members
|
||||
|
||||
def ask_byCountry(self,since=None):
|
||||
|
||||
''' Depreciated'''
|
||||
print("Go for coffee...")
|
||||
#get all the msg since "since variable" to today
|
||||
baseurl = "https://apps.fedoraproject.org/datagrepper/raw?topic=org.fedoraproject.prod.askbot.post.edit"
|
||||
|
|
@ -113,8 +113,11 @@ class geofp(object):
|
|||
|
||||
def plot_world2(self,title='Map', label='# Elements', filename='base_file', notebook=False):
|
||||
'''plot a fancy map with heat information '''
|
||||
import plotly.plotly as py
|
||||
import plotly.graph_objs as gobj
|
||||
import pandas as pd
|
||||
from iso3166 import countries
|
||||
from plotly.offline import download_plotlyjs,init_notebook_mode,plot,iplot
|
||||
init_notebook_mode(connected=notebook)
|
||||
|
||||
ct = Counter(self.members.country_code.values.tolist())
|
||||
del ct[None]
|
||||
|
|
@ -154,15 +157,17 @@ class geofp(object):
|
|||
showcountries = True,
|
||||
showcoastlines = False,
|
||||
projection = dict(
|
||||
type = 'Mercator'
|
||||
type = 'natural earth'
|
||||
)
|
||||
)
|
||||
)
|
||||
fig = dict( data=data, layout=layout )
|
||||
|
||||
fig = gobj.Figure(data = data,layout = layout)
|
||||
|
||||
if notebook:
|
||||
return py.iplot(fig,filename=filename )
|
||||
return iplot(fig,filename=filename )
|
||||
else:
|
||||
return py.plot(fig,filename=filename )
|
||||
return plot(fig,filename=filename )
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue