You really don't need an index, you can simply compare two rows and use them to filter the columns of the list.
df = pd.DataFrame({"col1": np.ones(10), "col2": np.ones(10), "col3": range(2,12)}) row1 = df.irow(0) row2 = df.irow(1) unique_columns = row1 != row2 cols = [colname for colname, unique_column in zip(df.columns, bools) if unique_column] print cols
If you know the standard value for each column, you can convert all rows to a list of logical elements, i.e.:
standard_row = np.ones(3) columns = df.columns unique_columns = df.apply(lambda x: x != standard_row, axis=1) unique_columns.apply(lambda x: [col for col, unique_column in zip(columns, x) if unique_column], axis=1)
Jeff tratner
source share