title: How to save columns seleted with iloc and find its mean
body: <p>this is my first post. I am currently working on a project where I need to find the mean for certain sections of data for each state. This is one example for the state data. I am using Google Colab, Python and the Pandas API to do this.</p>
  <p>I selected the column and rows needed using iloc command like this:</p>
  <p><code>AKInitialInvest = df.iloc[0:19, 7:8]</code></p>
  <p>and I tried to use the mean command:</p>
  <p><code>AK_Ini_Inv =  AKInitialInvest.mean(axis=1, skipna=False)</code></p>
  <p>but it did not work when I printed it so I tried to write it to the csv file like this:</p>
  <p><code>AK_Ini_Inv = AKInitialInvest.to_csv('SSBCI Transactions Dataset.csv', index = True )</code></p>
  <p>but when I printed the value stored, it just printed NaN for all of the rows.</p>
  <p>Anyone have any idea how to do this?</p>
  <p>Also does anyone have any idea on how to store these values in a new column and add it to the csv file? Thank you and happy holidays!</p>