-1

I got a df of more than 13000 of rows with more than 154 columns. I have a column: 'caseid' with a value of: 2298 and i want to print out that row with the value of other column with the name of 'prglngth'. The value that i looking for is in the key: 'prglngth'.

My steps were: first: find the index of the row of the value 2298 of the 'caseid' column. second: then try to match with the column: 'prglngth' to find the value of this column, and i already lost 48hs trying it. Any help will be appreciated!!

theletz
  • 1,713
  • 2
  • 16
  • 22
Aldo
  • 1
  • 1
  • 2
    kindly provide a minimal reproducible example : https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples – sammywemmy Feb 04 '20 at 21:16
  • 2
    `df.loc[df['caseid'].eq(2298), 'prglngth']`, before the comma specifies which row(s) you want to pick based on a condition, the second indicates which column you want by label (because `.loc`). You should have a look at the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html – ALollz Feb 04 '20 at 21:22

1 Answers1

0

Try to use:

df.loc[df['caseid'] == 2298, 'prglngth']
theletz
  • 1,713
  • 2
  • 16
  • 22