python - How can you just get the index of an already selected row in pandas? -


in [60]: print(row.index) int64index([15], dtype='int64') 

i know row number 15, in example. don't need know it's type or else. variable stores based on number is.

there else pandas wondering about. suppose returns 1 row:

row = df[df['username'] == "unique name"]   

is less proper use methods loc, iloc, etc? still work , everything, curious if still done way in larger projects.. there preferred methods if it's 1 row, opposed list of rows.

if write

row.index[0] 

then get, in case, integer 15.


note if check

dir(pd.int64index) 

you can see includes list-like method __getitem__.


Comments