original_docstring: 
              This function pretty prints the category totals by year, month and category.
          
docstring: This function pretty prints the category totals by year, month and category.
docstring_tokens: This function pretty prints the category totals by year month and category .
code: def print_category_total(bank_data, bank_categories, year, month_start, month_end, make_plot = False):
          '''
              This function pretty prints the category totals by year, month and category.
          '''
          # gather all the data and put everything into a dictionary
          category_total = {}
          for bank_index in range(0, len(bank_data)):
              if bank_data[bank_index]['date'].year == year:
                  if bank_data[bank_index]['date'].month >= month_start:
                      if bank_data[bank_index]['date'].month <= month_end:
                          # month range is correct now see if category exists as a dict key
                          if bank_categories[bank_index] in category_total.keys():
                              category_total[bank_categories[bank_index]] = category_total[bank_categories[bank_index]] + bank_data[bank_index]['amount']
                          else:
                              category_total[bank_categories[bank_index]] = bank_data[bank_index]['amount']
  
  		# now that we have gathered the data lets pretty print the results
          print("year: %d month start: %d month end: %d" % (year, month_start, month_end))
          print("{0:20} {1:10}".format("category", "total"))
          profit = 0
          #for category_key in category_total:
          for category_key in sorted(category_total):
              #print("{0:20} {1:10f}".format(category_key, category_total[category_key]))
              print("{0:20}  ${1:,.2f}".format(category_key, category_total[category_key]))
              profit += category_total[category_key]
  
          print("{0:20} ${1:,.2f}".format("profit:", profit))
  
          # create a plot if enabled
          if make_plot:
              category_list = list(category_total.values())
              category_name = list(category_total.keys())
              fix, ax = plt.subplots()
              width = 0.35
              N = len(category_list)
              ind = np.arange(N)
              rects1 = ax.bar(ind, category_list, width, color='y')
              ax.set_ylabel('Amount')
              ax.set_title('Category Amount from Month %d to %d' % (month_start, month_end))
              ax.set_xticks(ind + (width/2))
              ax.set_xticklabels(category_name, rotation=90)
              plt.tight_layout()
              plt.show()
code_tokens: def print_category_total ( bank_data , bank_categories , year , month_start , month_end , make_plot = False ) : category_total = { } for bank_index in range ( 0 , len ( bank_data ) ) : if bank_data [ bank_index ] [ 'date' ] . year == year : if bank_data [ bank_index ] [ 'date' ] . month >= month_start : if bank_data [ bank_index ] [ 'date' ] . month <= month_end : if bank_categories [ bank_index ] in category_total . keys ( ) : category_total [ bank_categories [ bank_index ] ] = category_total [ bank_categories [ bank_index ] ] + bank_data [ bank_index ] [ 'amount' ] else : category_total [ bank_categories [ bank_index ] ] = bank_data [ bank_index ] [ 'amount' ] print ( "year: %d month start: %d month end: %d" % ( year , month_start , month_end ) ) print ( "{0:20} {1:10}" . format ( "category" , "total" ) ) profit = 0 for category_key in sorted ( category_total ) : print ( "{0:20}  ${1:,.2f}" . format ( category_key , category_total [ category_key ] ) ) profit += category_total [ category_key ] print ( "{0:20} ${1:,.2f}" . format ( "profit:" , profit ) ) if make_plot : category_list = list ( category_total . values ( ) ) category_name = list ( category_total . keys ( ) ) fix , ax = plt . subplots ( ) width = 0.35 N = len ( category_list ) ind = np . arange ( N ) rects1 = ax . bar ( ind , category_list , width , color = 'y' ) ax . set_ylabel ( 'Amount' ) ax . set_title ( 'Category Amount from Month %d to %d' % ( month_start , month_end ) ) ax . set_xticks ( ind + ( width / 2 ) ) ax . set_xticklabels ( category_name , rotation = 90 ) plt . tight_layout ( ) plt . show ( )
short_docstring: This function pretty prints the category totals by year, month and category.
short_docstring_tokens: This function pretty prints the category totals by year month and category .
comment: '''
              This function pretty prints the category totals by year, month and category.
          '''$SEP$# gather all the data and put everything into a dictionary$SEP$# month range is correct now see if category exists as a dict key$SEP$# now that we have gathered the data lets pretty print the results$SEP$#for category_key in category_total:$SEP$#print("{0:20} {1:10f}".format(category_key, category_total[category_key]))$SEP$# create a plot if enabled