---
# System prepended metadata

title: Python Styler Example

---

# Python Styler Example
## Coloring Pandas Dataframe


```
def color_late(val): 
    c=''
    if (val <= 1440.0) & (val >= 0): 
        c = '#FFEB9C'
    elif val > 1440.0:
        c = 'PaleGreen'
    return 'background: %s' % c 
    

final_df = df1.style.background_gradient(cmap='Blues_r', vmin=2, vmax=10).set_precision(0).highlight_null('white').highlight_min(color='green').applymap(color_late)
```


### Once style is applied, it is no longer Pandas dataframe and you couldn't use Pandas functions. 
### set_precision is to set the decimal position.
### Colors do not transfer well to Excel.  If it needs to be written in Excel, you probably need to use Excelwriter formatter.
```

```