df remove all columns except code example
Example 1: pandas drop all columns except certain ones
df.drop(df.columns.difference(['a','b']), 1, inplace=True)
Example 2: python - remove repeted columns in a df
df.loc[:,~df.T.duplicated(keep='first')]