indexing - In PANDAS, how to get the index of a known value? -
if have known value in column, how can index-value? example:
in [148]: = pd.dataframe(np.arange(10).reshape(5,2),columns=['c1','c2']) in [149]: out[149]: c1 c2 0 0 1 1 2 3 2 4 5 ........ as know, can value index corresponding it, this.
in [151]: a.ix[0,1] in [152]: a.c2[0] in [154]: a.c2.ix[0] <-- use index out[151]: 1 out[152]: 1 out[154]: 1 <-- value but how index value?
there might more 1 index map value, make more sense return list:
in [48]: out[48]: c1 c2 0 0 1 1 2 3 2 4 5 3 6 7 4 8 9 in [49]: a.c1[a.c1 == 8].index.tolist() out[49]: [4]
Comments
Post a Comment