I have a data frame with 100 rows based on user's input I want to extract that particular row.
I have tried using if row==df.index
but it gives this error "The truth value of an array with more than one element is ambiguous"
Asked
Active
Viewed 571 times
-1
-
2To get a particular row use [iloc](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.iloc.html). So to get the i-th row you would have `row = df.iloc[i]` – DarrylG May 02 '21 at 11:35
-
Does this answer your question? [Selecting a row of pandas series/dataframe by integer index](https://stackoverflow.com/questions/16096627/selecting-a-row-of-pandas-series-dataframe-by-integer-index) – Tomerikoo May 02 '21 at 11:57
1 Answers
0
If user is inputting the row number i.e. integer location of the row then you can use df.iloc[I]
.
If user is inputting the index of the row, then you can use df.loc[I]
If something else then please update your question with more information

Shubham Periwal
- 2,198
- 2
- 8
- 26