title: How do I sum unique values per column in Python?
body: <p>I am working with weblogs and have data containing account_id and session_id. Multiple sessions can be associated with one account. I want to create a new dataframe containing account_id and count the number of unique sessions associated with that account. My df looks like this:</p>
  
  <pre><code>account_id session_id
   1111          de322
   1111          de322
   1111          de322
   1111          de323
   1111          de323
   0210          ge012
   0210          ge013
   0211          ge330
   0213          ge333
  </code></pre>
  
  <p>I'm using this code:</p>
  
  <pre><code>new_df = df.groupby(['account_id','session_id']).sum()
  </code></pre>
  
  <p>The output I am getting is below:</p>
  
  <pre><code> account_id     sessions
   1111           de322
                  de323
   0210           ge012 
                  ge013 
   0211           ge330
   0213           ge333
  </code></pre>
  
  <p>The output I'm expecting</p>
  
  <pre><code>account_id   sessions
   1111           2
   0210           2  
   0211           1
   0213           1
  </code></pre>
  
  <p>How should I fix it?</p>