#NEWLINE# def heatmap( data , precision , **kwargs ) : #NEWLINE# #INDENT# return_filenames = False #NEWLINE# return_spark = False #NEWLINE# return_both = False #NEWLINE# for ( key , value ) in kwargs . iteritems ( ) : #NEWLINE# #INDENT# if ( key == 'return_filenames' ) : #NEWLINE# #INDENT# if ( value == True ) : #NEWLINE# #INDENT# return_filenames = True #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( key == 'return_spark' ) : #NEWLINE# #INDENT# if ( value == True ) : #NEWLINE# #INDENT# return_spark = True #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( key == 'return_both' ) : #NEWLINE# #INDENT# if ( value == True ) : #NEWLINE# #INDENT# return_both = True #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# map_table ( data , precision , list = True ) #NEWLINE# data = pd . read_csv ( ( ( 'squares' + str ( precision ) ) + '.csv' ) ) #NEWLINE# maxvalue = data [ 'COUNT' ] . max ( ) #NEWLINE# factor = ( maxvalue / 5 ) #NEWLINE# factors = [ 0 , ( factor * 0.5 ) , ( factor * 1 ) , ( factor * 2 ) , ( factor * 3 ) , ( factor * 6 ) ] #NEWLINE# colors = [ '' , 'blue' , 'light blue' , 'light green' , 'yellow' , 'red' ] #NEWLINE# filenames = [ ] #NEWLINE# sparks = [ ] #NEWLINE# count = 0 #NEWLINE# for ( a , b ) in itertools . izip ( factors , colors ) : #NEWLINE# #INDENT# if ( count == 0 ) : #NEWLINE# #INDENT# count = 1 #NEWLINE# oldrow = a #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# temp = data [ ( ( data . COUNT >= oldrow ) & ( data . COUNT < a ) ) ] #NEWLINE# count += 1 #NEWLINE# oldrow = a #NEWLINE# temp [ 'color' ] = data #NEWLINE# if ( len ( temp ) == 0 ) : #NEWLINE# #INDENT# temp = [ temp . columns . values . tolist ( ) ] #NEWLINE# add = [ ] #NEWLINE# count2 = 0 #NEWLINE# while ( not ( count2 == len ( temp [ 0 ] ) ) ) : #NEWLINE# #INDENT# count2 += 1 #NEWLINE# add . append ( 0 ) #NEWLINE# #UNINDENT# temp = ( temp + [ add ] ) #NEWLINE# temp = list2df ( temp ) #NEWLINE# #UNINDENT# filenames . append ( ( str ( b ) + '.geojson' ) ) #NEWLINE# sparks . append ( [ temp , 'blocks' , ( str ( b ) + '.geojson' ) ] ) #NEWLINE# #UNINDENT# #UNINDENT# if ( return_filenames == True ) : #NEWLINE# #INDENT# return filenames #NEWLINE# #UNINDENT# if ( return_spark == True ) : #NEWLINE# #INDENT# return sparks #NEWLINE# #UNINDENT# if ( return_both == True ) : #NEWLINE# #INDENT# return [ filenames , sparks ]