I was wondering how I can remove all indexes that containing negative values inside their column. I am using Pandas DataFrames.
Format:
Myid - valuecol1 - valuecol2 - valuecol3 -... valuecol30
So my DataFrame is called data
I know how to do this for 1 column:
data2 = data.index[data['valuecol1'] > 0]
data3 = data.ix[data3]
So I only get the ids where valuecol1 > 0, how can I do some kind of and statement?
valuecol1 && valuecol2 && valuecol3 && ... && valuecol30 > 0 ?
解决方案
You could loop over the column names
for cols in data.columns.tolist()[1:]:
data = data.ix[data[cols] > 0]