'pd.style.applymap only to 1 CELL , accesed by row and column name/index
for index, rows in taxcode[['ITC Tax Code']].iterrows():
if str(taxcode['ITC Tax Code'][index]).endswith('ZERO') and taxcode['% VAT rate verification'][index] == 0.0:
print(f"Culoare verde pentru: {str(taxcode['ITC Tax Code'][index])}")
elif str(taxcode['ITC Tax Code'][index]).endswith('ZERO') and taxcode['% VAT rate verification'][index] != 0.0:
print(f"Culoare rosie pentru: {str(taxcode['ITC Tax Code'][index])}")
elif str(taxcode['ITC Tax Code'][index]).endswith('STD') and round(taxcode['% VAT rate verification'][index]) == 20:
print(f"Culoare verde pentru: {str(taxcode['ITC Tax Code'][index])}")
print(taxcode['% VAT rate verification'][index])
elif str(taxcode['ITC Tax Code'][index]).endswith('STD') and round(taxcode['% VAT rate verification'][index]) != 20:
print(f"Culoare rosie pentru: {str(taxcode['ITC Tax Code'][index])}")
print(taxcode['% VAT rate verification'][index])
so i have this code that checks for each row of a column if it has ZERO, and from the same row but from another column if the value is indeed 0. if this are met, i want to apply a background color to the %VAT rate verification column at the specific index.
i tried adding this after the check
if str(taxcode['ITC Tax Code'][index]).endswith('ZERO') and taxcode['% VAT rate verification'][index] == 0.0:
print(f"Culoare verde pentru: {str(taxcode['ITC Tax Code'][index])}")
taxcode['% VAT rate verification'][index].style.applymap('background-color = green')
but i get this error : AttributeError: 'float' object has no attribute 'style'
my question is, how can i apply a background color only to that cell at [column name][index] ?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
