notebooks/common.py
def add_data_points_by_pollster(ax, df, column, p_color, 
                                brand_col='Brand', 
                                date_col='Mean Date', no_label=False, marker=None):
    """Add individual poll results to the plot."""
    for i, brand in enumerate(sorted(df[brand_col].unique())):
        poll = df[df[brand_col] == brand]
        series = (
            poll[column].sum(axis=1, skipna=True) if type(column) is list 
            else poll[column]
        )
        label = None if no_label else brand
        m = marker if marker is not None else MARKERS[i]
        ax.scatter(poll[date_col], series, marker=m, 
                   c=p_color, s=20, label=label)
Add individual poll results to the plot.
Add individual poll results to the plot.
Add individual poll results to the plot .
def add_data_points_by_pollster(ax, df, column, p_color, 
                                brand_col='Brand', 
                                date_col='Mean Date', no_label=False, marker=None):
    for i, brand in enumerate(sorted(df[brand_col].unique())):
        poll = df[df[brand_col] == brand]
        series = (
            poll[column].sum(axis=1, skipna=True) if type(column) is list 
            else poll[column]
        )
        label = None if no_label else brand
        m = marker if marker is not None else MARKERS[i]
        ax.scatter(poll[date_col], series, marker=m, 
                   c=p_color, s=20, label=label)
def add_data_points_by_pollster ( ax , df , column , p_color , brand_col = 'Brand' , date_col = 'Mean Date' , no_label = False , marker = None ) : for i , brand in enumerate ( sorted ( df [ brand_col ] . unique ( ) ) ) : poll = df [ df [ brand_col ] == brand ] series = ( poll [ column ] . sum ( axis = 1 , skipna = True ) if type ( column ) is list else poll [ column ] ) label = None if no_label else brand m = marker if marker is not None else MARKERS [ i ] ax . scatter ( poll [ date_col ] , series , marker = m , c = p_color , s = 20 , label = label )
Add individual poll results to the plot.
Add individual poll results to the plot .
"""Add individual poll results to the plot."""
ax
df
column
p_color
brand_col
date_col
no_label
marker