title: How to make it so the year variable counts as a column?
body: <p>I currently have code to average the ratings of the movies by the year, but when it does this when I look at the shape it says I have 3 columns instead of 4 and I need the year to act as a column to do further analysis.</p>
  <p>This is the code I currently have to create a mean based on the year:</p>
  <pre><code>year_rating=movie_ratings.groupby(['year']).agg(lambda x: x.unique().sum()/x.nunique())
  </code></pre>
  <p>The table output:</p>
  <pre class="lang-none prettyprint-override"><code>year  movieId         userId         rating
  
  1874  148054.000000   76813.333333   3.000
  1878  148048.000000   76404.818182   3.000
  ...             ...            ...     ...
  2018  194400.452428   81183.849270   2.750
  2019  203531.063508   80773.959827   2.750
  
  [136 rows x 3 columns]
  </code></pre>
  <p>If there is a simpler way to take the average rating for each year I'm open to suggestions. I'm also looking for a way to make the column year an actual column as I get an error if I try to do linear regression.</p>
  <pre class="lang-none prettyprint-override"><code>AttributeError: 'DataFrame' object has no attribute 'year'
  </code></pre>