How to find out number of unique rows within a pandas groupby object?
<p>I know that we can use .nunique() on a groupby column to find out the unique number of elements in the column like below:</p>

<pre><code>df = pd.DataFrame({'c1':['foo', 'bar', 'foo', 'foo'], 'c2': ['A', 'B', 'A', 'B'], 'c3':[1, 2, 1, 1]})

    c1 c2  c3
0  foo  A   1
1  bar  B   2
2  foo  A   1
3  foo  B   1

df.groupby('c1')['c2'].nunique()

c1
bar    1
foo    2
Name: c2, dtype: int64
</code></pre>

<p>However, now I have a groupby object that contains multiple columns, is there any way to find out the number of unique rows?</p>

<pre><code>df.groupby('c1')['c2', 'c3'].???
</code></pre>

<hr>

<p>Update:
So the end result I want is the number of unique rows within each group that's grouped based on the 'c1' column, such as this:</p>

<pre><code>foo 2
bar 1
</code></pre>

<hr>

<p>Update 2:
Here's a new test dataframe:</p>

<pre><code>df = pd.DataFrame({'c1': ['foo', 'bar', 'foo', 'foo', 'bar'], 'c2': ['A'
, 'B', 'A', 'B', 'A'], 'c3': [1, 2, 1, 1, 1]})
</code></pre>

<p>Finally figured out how to do this!</p>

<pre><code>import pandas as pd
import numpy as np

df = pd.DataFrame({'c1': ['foo', 'bar', 'foo', 'foo', 'bar'],
                   'c2': ['A', 'B', 'A', 'B', 'A'],
                   'c3': [1, 2, 1, 1, 1]})

def check_unique(df):
    return len(df.groupby(list(df.columns.values)))

print(df.groupby('c1').apply(check_unique))
</code></pre>

python pandas dataframe group-by