title: Prepending total (sum, count) of each column of pandas dataframe to csv file
body: <p>I am trying to prepend Sum/Count of specific column to the pandas dataframe before writing it to a csv file. I came up with a really delicate solution and wondering if anyone can suggest a better approach. </p>
  
  <pre><code>`df.to_csv(out_path, index=False)
   #reading content of csv file
   with open(out_path,'r') as my_file:
       content = my_file.read()
   #adding comma in the line below adjust cell in csv file and appending content of pandas dataframe after writing aggregate total/sum. 
   with open(out_path,'w') as my_file:
       my_file.write(',,,,'+str(df['E'].count()))
       my_file.write(','+ str(df['F'].astype(float).sum()))
       my_file.write(',,,,,,,,,,,,,,'+ str(df['T'].astype(float).sum()))
       my_file.write('\n')
       my_file.write(content)`
  </code></pre>
  
  <p>Any help would be appreciated. </p>
  
  <p>Note: Total has to be on the top of the file before header. </p>
  
  <p>I am expecting following output:</p>
  
  <p><a href="https://i.stack.imgur.com/EinJf.png" rel="nofollow noreferrer">Sample Dataframe</a></p>