I have a pandas dataframe like this
**First_name Last_name Policy_number**
David Gilbert IOTA123455
Fredrick Manuel IOTA367522
Donald Trump IOTA337823
Cathy Jackso IOTA892352
And I have a variable like this in my python program:
some_value = "Trump"
The "some_value" can take any value from any column from the above pandas dataframe. My query has to find in which column that some_value is, and return the record.
Say for ex, if some_value = "Trump"
, my output should be:
**First_name Last_name Policy_number**
Donald Trump IOTA337823
Or if some_value = "IOTA123455"
, my output should be:
**First_name Last_name Policy_number**
David Gilbert IOTA123455
To achieve this, i have used the below code:
df.loc[(df['First_Name'].isin(some_value)) | df['Last_Name'].isin(some_values)] | df['Policy_Number'].isin(some_values)]
However i got the error as:
TypeError: only list-like objects are allowed to be passed to isin(), you passed a [str]
Is there any other way to solve this problem? Please help out.