"""
Simple Random Imputation
-----------------------
"""
import numpy as np
import pandas as pd


def random_imputation(data):
    """ Fill missing values in with a randomly selected value from the same column

    PARAMETERS
    ---------
    data: numpy.ndarray

    RETURNS
    ------
    numpy.ndarray
    """
    df = pd.DataFrame(data)

    for col in df:
        df_null = pd.isnull(df[col])
        if True in df_null.values:
            # .unique method includes null values so we have to drop it
            unique_values = [a_i for a_i in df[col].unique()
                             if not(a_i == ([] or 0 or None)) and
                             not np.isnan(a_i)]
            df[col][df_null] = np.random.choice(unique_values)
    filled_data = df.as_matrix()
    return filled_data

@@ -73,27 +73,46 @@
  np%0A
-import pandas as pd
+from impy.diagnostics import find_null
 %0A%0A%0Ad
@@ -334,135 +334,67 @@
     
-df = pd.DataFrame(data)%0A%0A    for col in df:%0A        df_null = pd.isnull(df%5Bcol%5D)%0A        if True
+null_xy = find_null(data)%0A    for x, y
  in 
-df_
 null
-.values:%0A   
+_xy:%0A
         
  # .
@@ -393,68 +393,39 @@
     
- # .
 unique
- method includes null values so we have to drop it
+s = np.unique(data%5B:, y%5D)
 %0A   
@@ -433,160 +433,27 @@
     
-    
 unique
-_values = %5Ba_i for a_i in df%5Bcol%5D.unique()%0A                             if not(a_i == (%5B%5D or 0 or None)) and%0A                             not 
+s = uniques%5B~
 np.i
@@ -461,11 +461,15 @@
 nan(
-a_i
+uniques
 )%5D%0A 
@@ -479,27 +479,17 @@
     
-    df%5Bcol%5D%5Bdf_null
+data%5Bx%5D%5By
 %5D = 
@@ -515,68 +515,22 @@
 ique
-_value
 s)%0A    
-filled_data = df.as_matrix()%0A    return filled_
+return 
 data

remove dependency on pandas