I am trying to search a keyword in pandas dataframe. Currently I am using isin() method to search the entire dataframe, it is working correctly but it is taking a lot of time when dealing with big dataset exceeding 1 Gb.
The problem I am addressing is :
Suppose I have a dataset df :
Player_Name Country Type_of_sports
Messi Argentina Football
Ronaldo Portugal Football
Kohli India Cricket
Federer Switzerland Tennis
Column name - Player_Name, Country,Type_of_sports
So if a user enters a query for example:
query = 'Which country is Messi from ?'
So my keyword in this query will be Messi
.
So now I need to search for Messi
in my entire dataframe.
So is there any efficient method to search and find such data values in data-frame without using for loop or isin() method??
Note - It is not always the case that the query will always contain the exact column name.
For example -
new_query- 'Name of players playing football
'.
Now here I need to search for keyword Football
in the entire data-frame.
Is there any method to search for Football
without using for loop or isin() function.
Thank you