[Python] Conditionally color dataframe cells in python terminal

Discussão em 'Python' iniciado por Stack, Dezembro 1, 2024.

  1. Stack

    Stack Membro Participativo

    I have a dataframe.

    import pandas as pd

    data = {
    "Name": ['Alice','Bob', 'Sue','Joe','rose','cindy'],
    "Age": [11, 6, 3, 16, 21, 8],
    "Num": [2, 17, 12, 7, 22, 9],
    "Score": [3, 8, 13, 18, 3, 23],
    "Dep": [4, 19, 8, 11, 6, 20],
    }

    df = pd.DataFrame(data)


    I want cells of column "Name" to be colored in python terminal which have "Age" greater than "Num"

    Continue reading...

Compartilhe esta Página