Horje
how to change colour of rows in csv using pandas Code Example
how to change colour of rows in csv using pandas
import numpy as np
import pandas as pd


df = pd.DataFrame([[8484,-1.15],[1390,3.5],[327,10.5],[1135,3.3],[6499,2.0],[1055,4.0]], columns=['data1','dat2'])


def color_rule(val):
    return ['background-color: red' if x >= 3 else 'background-color: yellow' for x in val]

html_column = df.style.apply(color_rule, axis=1, subset=['dat2'])

html_column.to_excel('styled.xlsx', engine='openpyxl')

html_column
how to change colour of rows in csv using pandas
import numpy as np
import pandas as pd


df = pd.DataFrame([['ex1',8484,-1.15],['ex2',1390,3.5],['ex3',327,10.5],['ex4',1135,3.3],['ex5',6499,2.0],['ex6',1055,4.0]], columns=['tag','data1','dat2'])


def color_rule(tag):
    var1 = df['dat2'][df['tag'] == tag.values[0]]
    return ['background-color: red' if x >= 3 else 'background-color: yellow' for x in var1]

html_column = df.style.apply(color_rule, axis=1, subset=['tag'])

html_column.to_excel('styled.xlsx', engine='openpyxl')




Python

Related
The name tf.summary.merge_all is deprecated. Please use tf.compat.v1.summary.merge_all Code Example The name tf.summary.merge_all is deprecated. Please use tf.compat.v1.summary.merge_all Code Example
QTableWidget as a button pyqt Code Example QTableWidget as a button pyqt Code Example
web scraping linkedin profiles python jupyter Code Example web scraping linkedin profiles python jupyter Code Example
changing instance through dict changes all instances Code Example changing instance through dict changes all instances Code Example
join pyspark stackoverflow Code Example join pyspark stackoverflow Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7