Some helper functions to 'wrangle' the data once in pandas.
   
    
    
    
    
   
# tests
df = pd.DataFrame([
    [1,2,3,4],
    [1,20,30,4],
    [1,200,300,40],
    [1,2000,3000,40],
    [1,20000,30000,400],
    [10,200000,300000,400],
], columns=['col0','col1','col2','col3'])
# check that col0 is removed as it only has 2 unique values
assert 'col0' not in drop_low_uniqueness_cols(df, nunique_thold=2).columns
# check that col3 is removed as it only has 50% unique values
assert 'col3' not in drop_low_uniqueness_cols(df, nunique_thold=0.5).columns
#tests
df = pd.DataFrame([
    [1,2,3,4],
    [1,20,30,4],
    [1,200,300,40],
    [1,2000,3000,40],
    [1,20000,30000,400],
    [1.1,200000,300000,400],
], columns=['col0','col1','col2','col3'])
# check that col0 is removed as it only has 2 unique values and a low std value (0.040825)
assert 'col0' not in drop_low_std_cols(df, std_thold=0.05).columns