title: Multiple dataframe groupby Pandas
body: <p>I have 2 datasets to work with:</p>
  <pre><code>ID Date       Amount   
  1  2020-01-02 1000
  1  2020-01-09 200
  1  2020-01-08 400
  </code></pre>
  <p>And another dataset which tells which is most frequent day of week and most frequent week of month for each ID(there are multiple such IDs)</p>
  <pre><code>ID Pref_Day_Of_Week_A Pref_Week_Of_Month_A 
  1  3                 2
  </code></pre>
  <p>For this ID ,Thursday was the most frequent day of the week for ID 1 and 2nd week of the month was the most frequent week of the month.</p>
  <p>I wish to find sum of all the amounts that took place on the most frequent day of week and frequent week of month, for all IDs(hence requiring groupby):</p>
  <pre><code>ID Amount_On_Pref_Day Amount_Pref_Week
  1  1200               600
  </code></pre>
  <p>I would really appreciate it if anyone could help me calculating this dataframe using pandas. For reference, I have used this function to find the week of month for a given date:</p>
  <pre><code>#https://stackoverflow.com/a/64192858/2901002
  def weekinmonth(dates):
      &quot;&quot;&quot;Get week number in a month.
      
      Parameters: 
          dates (pd.Series): Series of dates.
      Returns: 
          pd.Series: Week number in a month.
      &quot;&quot;&quot;
      firstday_in_month = dates - pd.to_timedelta(dates.dt.day - 1, unit='d')
      return (dates.dt.day-1 + firstday_in_month.dt.weekday) // 7 + 1
  </code></pre>