Pandas

Filter

  1. filter with multiple condition

    df_filtered = df[ (df.D>0) & df.C<0) ]
    df_filtered = df[ (df['D']>0) & df['C']<0) ]
    
  2. filter with isin

    alist = [12,312,53]
    df_filtered = df[ df['D'].isin(alist) ]
    
  3. Ref

Indicator of apply when using pandas

  1. using the tqdm model

    originally:

    df.groupby(['feature1', 'feature2']).apply(feature_rollup)
    

    using tqdm:

    from tqdm import tqdm
    tqdm.pandas(tqdm())
    df.groupby(['feature1', 'feature2']).progress_apply(feature_rollup)
    
  2. Ref

Handle Large scale data

  1. Ref

Melting data frames

  1. Ref