I'm trying read data file csv, that done, but I want to write another data with some conditions add style(color, both...) for data in csv file.
i) I read the data from a file csv, is a simple test file first to apply a large data file latter, so the data test is file is
cod price var
AMZ 8484 -1.15
BABA 1390 3.5
GOGL 327 -10.5
MSFT 1135 3.3
VISA 6499 2.0
PBB 1055 4.0
CHC 3455 1.1
IFT 5228 -4.0
FRA 4555 2.0
ii) put conditions and read only values which column var > 1
iii) put back ground color in the cod column:
red where var => 3
yellow where var = 2 <3
iv) save in another data csv
my code until moment is:
import pandas as pd
df = pd.read_csv("teste.csv")
f1 = df['var'] > 1
df[f1].to_csv('export.csv')
I don't know how use style in pandas, can you please help me this case?