So, I have two dataframes. the first dataframe is dataset conatians several columns, what i will use in this dataframe is the dataset['text_msg'], this columns contains text data.
The second Dataframe sentences_to_exclude contains the data which type is text type.
The column that i will use in this dataframe is sentences_to_exclude['sentences'].
What i need to do is to verify if there are sentences from sentences_to_exclude['sentences'] in the first dataframe and remove the whole sentence.
I have tried a function but it didn't work for me: Here is the function i've used ==>
def remove_words(data):
words_to_remove = sentences_to_exclude['sentences'].lower().split(" ")
text_body = dataset['text_msg']
for word in words_to_remove:
text_body = text_body.replace(word,'' )
return text_body
Here's an exemple of sentences_to_exclude['sentences']
pour un traitement optimal de votre demande, veuillez indiquer les informations ci-dessous
and for the fisrt data frame here's an example of the dataset['text_msg']:
pour un traitement optimal de votre incident, nous vous prions de renseigner les informations ci-dessous : - code transaction : - numero de facture / commande client : - criteres dexecution et message derreur (a attacher en pj) description detaillee de votre demande
Hope that my request is clear Thank you for help in advance
Example Data
sentences = ['code transaction', 'Pour un traitement efficace']
text = [ ' i should delete code transaction ', ' i am trying to delete Pour un traitement efficace only from this sentence ' ]
df1 = pd.DataFrame({'Sentences ': sentences })
df2 = pd.DataFrame({'Text': text})