Conditional Formatting for Rows with Similar Results

Comments

1 comment

  • Avatar
    Charlotte Campbell (Edited )

    [Written by James Camagong]

    Same idea but using a Plotly table which can handle more rows and is easier to resize:

    import plotly
    import plotly.graph_objs as go
    import numpy as np
    import pandas as pd
    from datetime import datetime
    
    colors = []
    global val
    val = df['id'][0]
    global change
    change = 0
    for i in range(df.shape[0]):
        if val != df['id'][i]:
            change += 1
        if (change % 2 == 0):
            colors.append('#000000')
        else:
            colors.append('#DB3EB1')
        val = df['issue_id'][i]
    
    --the below is to make timestamps show on the table as timestamps instead of integers
    df['timestamp'] = df['timestamp'].map(lambda t: t.strftime('%Y-%m-%d %H:%M'))
    df['timestamp'] = (df['timestamp']).apply(str)
    
    col = df.col.values
    --and so on for all the columns^^^
    
    
    trace = go.Table(columnwidth=[.06, .2, .2, .9, .3, .2, .2],
                     header=dict(values=['col2', 'col3', 'col4', 'col5', 'col6', 'col7'],
                                 fill=dict(color='#41B6E6'),
                                 font=dict(color='black', size=12),
                                 align=['left']),
                     cells=dict(values=[col2, 'col3', 'col4', 'col5', 'col6', 'col7'],
                                fill=dict(color=[colors]),
                                align=['left'] * 8,
                                line=dict(color='#41B6E6'),
                                font=dict(color='white', size=12)))
    
    data = [trace]
    
    periscope.plotly(data)
    0
    Comment actions Permalink

Please sign in to leave a comment.