#3 Migrating the plot_world2 method to the new Plotty API
Merged 3 years ago by bt0dotninja. Opened 3 years ago by bt0dotninja.
fedora-commops/ bt0dotninja/geofp master  into  master

Migrating the plot_world2 method to the new Plotty API
Alberto Rodriguez Sanchez • 3 years ago  
file modified
+2 -1
@@ -1,6 +1,7 @@ 

  *.csv

+ *.html

  *.cfg

  *.svg

  __pycache__

  .vscode/

- myconfig.cfg 

\ No newline at end of file

+ myconfig.cfg

@@ -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))

file modified
+5 -2
@@ -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))

file modified
+11 -6
@@ -62,7 +62,7 @@ 

          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 @@ 

              

      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 @@ 

              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 )

          

   

  

Pull-Request has been merged by bt0dotninja

3 years ago