Re: [scikit-learn] Identifying column names of Non-zero values

2016-10-05 Thread Startup Hire
Hi Samo, Thanks a lot. It works at a row level and I can append it a row level to the main dataframe to do further analysis. Regards, Sanant On Wed, Oct 5, 2016 at 5:05 PM, Samo Turk wrote: > Something like this might work: > > def non_zero(row, columns): > return list(columns[~(row == 0)]

Re: [scikit-learn] Identifying column names of Non-zero values

2016-10-05 Thread Maciek Wójcikowski
Hi Sanant and Samo, Even easier and faster solution: > df.columns[(df.values != 0).any(axis=0)] Or if some reason != 0 does not work for you: > df.columns[(~(df.values == 0)).any(axis=0)] Pozdrawiam, | Best regards, Maciek Wójcikowski [email protected] 2016-10-05 13:35 GMT+02:00 Sa

Re: [scikit-learn] Identifying column names of Non-zero values

2016-10-05 Thread Samo Turk
Something like this might work: def non_zero(row, columns): return list(columns[~(row == 0)]) df.apply(lambda x: non_zero(x, df.columns), axis=1) Cheers, Samo On Wed, Oct 5, 2016 at 11:58 AM, Startup Hire wrote: > Hi Pypers, > > Hope you are doing well. > > I am working on a project to fi

[scikit-learn] Identifying column names of Non-zero values

2016-10-05 Thread Startup Hire
Hi Pypers, Hope you are doing well. I am working on a project to find out the column names of non-zero values at a row level. How can this effectively done in python pandas/dataframe? For example, *Column1* *Column *2 *Column *3 Column 4 Column 5 Column 6 *Column 7* New column t