So here is an analogous situation of what I am trying to do
data = pd.read_csv(data)
df = pd.DataFrame(data)
print(df)
The data frame looks as follows
... 'd1' 'd2' 'd3... 'd13'
0 ... 0 0 0... 0
1 ... 0 0.95 0... 0
2 ... 0 0.95 0.95... 0
So on and so forth, essentially I would like to select these last 13 columns of my data frame, and count how many per row are greater than a certain value, and then append that to my data frame.
I figure there must be a simple way, I have been trying to use df.iloc[:, 21:]
as my first column of interest begins here, however from this point on, I feel stuck. I have been trying many different methods such as criteria
and for loops. I know this is a trivial thing but I have spent hours on it. Any help would be much appreciated.
for x in df:
a = df.iloc[:,21:].values()
if a.any[:, 12] > 0.9:
a[x] = 1
else:
a[x] = 0
sumdi = sum(a)
df.append(sumdi)