title: TypeError: Object of type int64 is not JSON serializable | pandas aggregation functions and json.dumps() error
body: <p>Pandas aggregation functions return TypeError: Object of type int64 is not JSON serializable.</p>
  <p>Here is the dataframe:</p>
  <pre><code>d = {'col1': [1, 2], 'col2': [3, 4]}
  df = pd.DataFrame(data=d)
  df
  Out[47]: 
     col1  col2
  0     1     3
  1     2     4
  </code></pre>
  <p>Here is how I am aggregating the column:</p>
  <pre><code>sum_col = df.col1.sum()
  sum_col
  Out[49]: 3
  </code></pre>
  <p>But as soon as I do json.dumps() it gives a type error:</p>
  <pre><code>data = json.dumps(sum_col)
  data
  ---------------------------------------------------------------------------
  TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-50-5d4b966e64cc&gt; in &lt;module&gt;
  ----&gt; 1 data = json.dumps(sum_col)
        2 data
  TypeError: Object of type int64 is not JSON serializable
  
  </code></pre>