Sample null rows form a pandas data frame
https://stackoverflow.com/questions/21202652/getting-all-rows-with-nan-value
#+begin_src python :results output

import pandas as pd
import numpy as np

# create a frame with some nulls
ndf =pd.DataFrame({'a':[1,2,3,44],'b':[3,np.nan,5,55],'c':[np.nan, 4,5,np.nan]})

# print the frame
print(ndf)

# define a function to sample rows with mulls

def sample_nulls(df):
    """Print a few rows from a dataframe for each columm with null fields"""
    max_rows_to_print = 5
    for col in df.columns:
        nulls=df[pd.isnull(df[col])]
        how_many = len(nulls)
        if how_many > 0:
            num_to_print=min(max_rows_to_print,how_many)
            print("Column ", col, " has ", how_many, " rows with nulls.  Printing ", num_to_print)
            print(nulls.iloc[0:num_to_print])
            #ndf[pd.isnull(ndf['c'])].iloc[0:2]


# use the function
sample_nulls(ndf)

#+end_src

#+RESULTS:
#+begin_example
    a     b    c
0   1   3.0  NaN
1   2   NaN  4.0
2   3   5.0  5.0
3  44  55.0  NaN
Column  b  has  1  rows with nulls.  Printing  1
   a   b    c
1  2 NaN  4.0
Column  c  has  2  rows with nulls.  Printing  2
    a     b   c
0   1   3.0 NaN
3  44  55.0 NaN
#+end_example
