#1 head map
Merged 6 years ago by bt0dotninja. Opened 6 years ago by bt0dotninja.

Correct method comment
Renato Silva • 6 years ago  
file modified
+2
@@ -2,3 +2,5 @@ 

  *.cfg

  *.svg

  __pycache__

+ .vscode/

+ myconfig.cfg 

\ No newline at end of file

file modified
+30 -3
@@ -73,7 +73,7 @@ 

          else:

              params={'page':1,'rows_per_page':100, 'size':'small'}

          

-         results= requests.get(baseurl,params=params).json()

+         results = requests.get(baseurl,params=params).json()

          for i in range(results['pages']):

              for msg in results['raw_messages']:

                  if msg['msg']['created']: 
@@ -166,5 +166,32 @@ 

          

   

  

-     def plot_heat(self,title):

-         pass

+     def plot_heat(self, title='test', filename='base_file', label='label', notebook=False):

+         '''plots heatmap with location/number of asked questions '''

+         import plotly.plotly as py

+         import plotly.graph_objs as go

+         from iso3166 import countries

+ 

+         ct = Counter(self.members.country_code.values.tolist())

+         del ct[None]

+ 

+         locations=[]

+         z=[]

+         names=[]

+         for k in ct.keys():

+             try:

+                 country=countries.get(k)

+                 locations.append(country[2])

+                 z.append(ct[k])

+                 names.append(country[0])

+             except:

+                 continue

+ 

+         z = pd.Series(z)

+         trace = go.Heatmap(z = [z], x = names)

+         data = [trace]

+ 

+         if notebook:

+             return py.iplot(data,filename=filename )

+         else:

+             return py.plot(data,filename=filename )

file modified
+4 -3
@@ -11,7 +11,8 @@ 

  

  if __name__=='__main__':

      gp=geofp('myconfig.cfg')

-     df=gp.ask_byCountry(datetime(2017,4,1))

-     print("Follow the link")

-     print(gp.plot_world2(title='Fedora Ask questions by country since 04/01/2017',label='questions by country',filename='Fedora-Ask', notebook=False))

+     df=gp.ask_byCountry(datetime(2017,4,15))

+     print("Follow the links")

+     print(gp.plot_world2(title='Fedora Ask questions by country since 04/15/2017',label='questions by country',filename='Fedora-Ask', notebook=False))

      df.to_csv('AskFedora.csv')

+     print(gp.plot_heat(title='Fedora Ask questions by country since 04/15/2017',label='questions by country',filename='Fedora-Ask', notebook=False))

Pull-Request has been merged by bt0dotninja

6 years ago