0

I need to highlight (underline/italic/Bold/Color) some words present in a text based on the list for each row arranged in a pandas dataframe. something like this. The list has the words in lower case only, but the words in text can be of lower/title/uppercase.In stackoverflow i could not make the words italic so put stars to highlight.

import pandas as pd
data = [[1, 'I love *Mangoes*','['Mangoes]'], [2,'Along with *mangoes* i like *Oranges* as well','['mangoes',
'oranges']'], [3,'My brother neither likes *Mangoes* nor *Oranges*','['mangoes','oranges']']
df = pd.DataFrame(data, columns = ['ID', 'Text','List_of_words'])
9
  • 1
    The dataframe isnot reproducible (it runs into errors) , can you please fix that Commented Jan 14, 2020 at 15:44
  • Where shall the highlighting happen? Is the text going to be in an HTML, markdown or anything like that? Because in simple dataframe, you can only highlight whole cells, i guess. See stackoverflow.com/questions/49961211/… Commented Jan 14, 2020 at 16:27
  • Yes, but can HTML be represented in a data frame? I need to produce the output in a dB table. Please advise Commented Jan 15, 2020 at 5:22
  • something like pandas styling Commented Jan 22, 2020 at 16:36
  • Do you only need to add <b>/</b> around the words in the List_of_words column, or is the word list universal for all data? Commented Mar 14, 2020 at 21:32

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.