i have following dateframe:
record_id month day year plot species sex wgt 33320 33321 1 12 2002 1 dm m 44 33321 33322 1 12 2002 1 m 58 ... ... ... ... ... ... ... ... ...
i want display columns year wgt values equal 27. have done on 2 lines:
df_slice = df[df.year == 27] df_slice = df_slice.ix[:,'year':]
is there way reduce 1 line?
you can use ix
:
print (df.ix[df.year == 27, 'year':])
sample (value 2001
added):
print (df) record id month day year plot species sex wgt 0 33320 33321 1 12 2001 1 dm m 44 1 33321 33322 1 12 2002 1 m 58 print (df.ix[df.year == 2001, 'year':]) year plot species sex wgt 0 2001 1 dm m 44
Comments
Post a Comment