title: Calculate Monthly Variability by Long-Term Average Pandas
body: <p>i have data that looks like this in dataframe &quot;YM&quot;showing the values for the year 2019 for months 8-12:</p>
  <pre><code>     year    month  adjusted_power
  343  2019    08     20754.20750
  344  2019    09     20305.95125
  345  2019    10     18428.88125
  346  2019    11     27864.02500
  347  2019    12     25405.17500
  </code></pre>
  <p>And, I have monthly averages in a dataframe called &quot;YMmonthmean&quot; that looks like this -</p>
  <pre><code>      month  adjusted_power_AVERAGE
  7     08    26161.086034
  8     09    20707.108319
  9     10    25684.728190
  10    11    29468.227759
  11    12    29509.313319
  </code></pre>
  <p>I'm trying to calculate the variability of each &quot;year&quot; value using the adjusted_power_AVERAGE column so that the result looks like this -</p>
  <p><a href="https://i.stack.imgur.com/YlryP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YlryP.png" alt="required output" /></a></p>
  <p>I have tried variations of this below with differing errors. Both the variables YM and YMmonthmean are dataframes. Thank you for your assistance.</p>
  <pre><code>#NEED VARIABILITY BY MONTH AND YEAR
  df_final = (YM.div(YMmonthmean.loc[1], axis=1) - 1)
  </code></pre>
  <p>Error most recent:
  TypeError: unsupported operand type(s) for /: 'str' and 'str'</p>