title: Calculate average of every n rows from a csv file
body: <p>I have a csv file that has 25000 rows. I want to put the average of every 30 rows in another csv file.</p>
  <p>I've given an example with 9 rows as below and the new csv file has 3 rows <strong>(3, 1, 2)</strong>:</p>
  <pre><code>|   H    |
   ========
  |   1    |---\
  |   3    |   |---&gt;| 3 |
  |   5    |---/
  |  -1    |---\
  |   3    |   |---&gt;| 1 |
  |   1    |---/
  |   0    |---\
  |   5    |   |---&gt;| 2 |
  |   1    |---/
  </code></pre>
  <p><strong>What I did:</strong></p>
  <pre><code>import numpy as np
  import pandas as pd
  
  m_path = &quot;file.csv&quot;
  
  m_df = pd.read_csv(m_path, usecols=['Col-01']) 
  m_arr =  np.array([])
  temp = m_df.to_numpy()
  step = 30
  for i in range(1, 25000, step):
      arr = np.append(m_arr,np.array([np.average(temp[i:i + step])]))
  
  data = np.array(m_arr)[np.newaxis]
  
  m_df = pd.DataFrame({'Column1': data[0, :]})
  m_df.to_csv('AVG.csv')
  </code></pre>
  <p>This works well but <strong>Is there any other option to do this?</strong></p>