Grouping python pandas
Question: Could you tell me how to group a table (from products1.txt file) like
following:

    
    
    Age;Name;Country
    10;Valentyn;Ukraine
    12;Igor;Russia
    12;Valentyn;
    10;Valentyn;Russia
    

So I can find out how many Valentyns have an empty "Country" cell.  
I ran the following code:

    
    
    import pandas as pd
    df = pd.read_csv('d:\products1.txt', sep = ";")
    result = df[(df["Name"] == "Valentyn") & (df["Country"] == None)]
    

But I get an error...


Answer: You should use `isnull` (rather than `== None`) to check for `NaN`:

    
    
    In [11]: df[(df.Country.isnull()) & (df.Name == 'Valentyn')]
    Out[11]:
       Age      Name Country
    2   12  Valentyn     NaN
    

Another option would be to check those which had Country `NaN` and then count
the values:

    
    
    In [12]: df.Name[df.Country.isnull()]
    Out[12]:
    2    Valentyn
    Name: Name, dtype: object
    
    In [13]: df.Name[df.Country.isnull()].value_counts()
    Out[13]:
    Valentyn    1
    dtype: int64
    

