title: Pandas DF - Group by Sender, Calculate "Frequency" of Emails
body: <p>I have 15,000+ emails in my inbox and I am trying to clean it up. I currently have a script that has collected all my email data, but now I am trying to find out which domains are emailing me the most and at what rate. I currently have a pandas dataframe that is a series of emails and the date I received it like this (this is the list/dictionary form pre-dataframe)</p>
  <pre><code>[{'epoch': '1613345709000',
   'date': '2021-02-14 23:35:09',
   'domain': 'amazon.com',
   'From': 'store-news@amazon.com'},
  {'epoch': '1613320070000',
   'date': '2021-02-14 16:27:50',
   'domain': 'email.vans.com',
   'From': 'vansinfo@email.vans.com'}]
  </code></pre>
  <p>What I am essentially trying to do next is calculate the frequency that each of these senders are sending me on a monthly basis.</p>
  <p>I have this all in my jupyter notebook so eventually want visualize the data.</p>
  <p>The struggle I am running into is the frequency part when I do a groupby. I am having a hard time figuring out if I need a Lambda to convert this data, or if there is some additional group section other than sum() or mean() to get this data.</p>
  <p>So an example output I am looking for after a group by is like,</p>
  <pre><code>from : store-news@amazon.com, frequency : 35
  </code></pre>
  <p>OR</p>
  <pre><code>domain : amazon.com, frequency : 35
  </code></pre>
  <p>Frequency being the average I get per month.</p>
  <p>So far I have done basic things like</p>
  <p>So far I have mainy just done:</p>
  <pre><code>newdata = email_df.groupby(by=&quot;domain&quot;).sum()
  
  newdata = email_df.groupby(by=&quot;domain&quot;).average()
  </code></pre>
  <p>but it complains about lack of int, so not even sure how to work with dates here.</p>