Python function for recursively remove data from a list -


i have pandas dataframe following(c2).

session   1    2        3         5         8 session                                       1       nan  0.8  0.67082  0.676123  0.730297 2       nan  nan  0.67082  0.845154  0.912871 3       nan  nan      nan  0.566947  0.612372 5       nan  nan      nan       nan  0.925820 8       nan  nan      nan       nan       nan 

and list of values.

listofdata = [1,2,3,4,5,6,7,8,9,10] 

i 2 list of tuples following

greater = [(c2.index[i], c2.columns[j]) i, j in np.argwhere(c2 > 0.8)] less = [(c2.index[i], c2.columns[j]) i, j in np.argwhere(c2 < 0.8)] 

for 'greater' following values get. [(2, 5), (2, 8), (5, 8)] .i want find how these 2,5 , 8 grouped. first want find maximum 3 groups.

b = [] item in greater:         b.append( c2.ix[item] )         maxindex = [(c2.index[i], c2.columns[j]) i, j in np.argwhere(c2 == max(b))] 

since maximum (5,8) want remove both 5 , 8 initial 'listofdata'.

k = [j in maxindex j in i]         in k:             try:                 listofdata.remove(i)             except valueerror:                 pass 

now listofdata = [1, 3, 4, 6, 7, 9, 10] remaining (2, 5), (2, 8) since 5 , 8 has gone 'listofdata' can ignore both of them. same process should done 'less' also. in formulating function.


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -