请尝试以下代码示例:import pandas as pd
Fruits = ('Apple', 'Mango', 'Grapes', 'Banana', 'orange')
Price = (100, 80, 50, 90, 60)
direction = (1, 0, 1, 1, 0)
df = pd.DataFrame({'Fruits': Fruits, 'Price': Price,'direction':direction})
df.direction.replace([1, 0],["↑", "↓"], inplace=True) #replace the values using html codes for up and down arrow.
html_df= df.to_html() #convert the df to html for better formatting view
html_df = html_df.replace("
↓"," ↓") # Remove extra tags and added red colour to down arrowhtml_df = html_df.replace("
↑"," ↑") # Remove extra tags and added green colour to up arrowprint(html_df) #print the df
浏览器中的输出文件: