Python – color DF cell by hex value in cell
Question:
Answers:
DataFrame.style
is what you’re after:
import pandas as pd
df = pd.DataFrame({"hex1":["#dcddde", "#954eff"], "hex2":["#ffba00","#b889ff"]})
df.style.applymap(lambda hex_color: f"background-color: {hex_color}")
DataFrame.style
is what you’re after:
import pandas as pd
df = pd.DataFrame({"hex1":["#dcddde", "#954eff"], "hex2":["#ffba00","#b889ff"]})
df.style.applymap(lambda hex_color: f"background-color: {hex_color}")