sportsref/nba/pbp.py
def get_sparse_lineups(df):
    """TODO: Docstring for get_sparse_lineups.

    :param df: TODO
    :returns: TODO
    """

    # get the lineup data using get_dense_lineups if necessary
    if (set(ALL_LINEUP_COLS) - set(df.columns)):
        lineup_df = get_dense_lineups(df)
    else:
        lineup_df = df[ALL_LINEUP_COLS]

    # create the sparse representation
    hm_lineups = lineup_df[HM_LINEUP_COLS].values
    aw_lineups = lineup_df[AW_LINEUP_COLS].values
    # +1 for home, -1 for away
    hm_df = pd.DataFrame([
        {'{}_in'.format(player_id): 1 for player_id in lineup}
        for lineup in hm_lineups
    ], dtype=int)
    aw_df = pd.DataFrame([
        {'{}_in'.format(player_id): -1 for player_id in lineup}
        for lineup in aw_lineups
    ], dtype=int)
    sparse_df = pd.concat((hm_df, aw_df), axis=1).fillna(0)
    return sparse_df
def get_sparse_lineups(df):
    """TODO: Docstring for get_sparse_lineups.

    :param df: TODO
    :returns: TODO
    """

    # get the lineup data using get_dense_lineups if necessary
    if (set(ALL_LINEUP_COLS) - set(df.columns)):
        lineup_df = get_dense_lineups(df)
    else:
        lineup_df = df[ALL_LINEUP_COLS]

    # create the sparse representation
    hm_lineups = lineup_df[HM_LINEUP_COLS].values
    aw_lineups = lineup_df[AW_LINEUP_COLS].values
    # +1 for home, -1 for away
    hm_df = pd.DataFrame([
        {'{}_in'.format(player_id): 1 for player_id in lineup}
        for lineup in hm_lineups
    ], dtype=int)
    aw_df = pd.DataFrame([
        {'{}_in'.format(player_id): -1 for player_id in lineup}
        for lineup in aw_lineups
    ], dtype=int)
    sparse_df = pd.concat((hm_df, aw_df), axis=1).fillna(0)
    return sparse_df
def get_sparse_lineups ( df ) : # get the lineup data using get_dense_lineups if necessary if ( set ( ALL_LINEUP_COLS ) - set ( df . columns ) ) : lineup_df = get_dense_lineups ( df ) else : lineup_df = df [ ALL_LINEUP_COLS ] # create the sparse representation hm_lineups = lineup_df [ HM_LINEUP_COLS ] . values aw_lineups = lineup_df [ AW_LINEUP_COLS ] . values # +1 for home, -1 for away hm_df = pd . DataFrame ( [ { '{}_in' . format ( player_id ) : 1 for player_id in lineup } for lineup in hm_lineups ] , dtype = int ) aw_df = pd . DataFrame ( [ { '{}_in' . format ( player_id ) : - 1 for player_id in lineup } for lineup in aw_lineups ] , dtype = int ) sparse_df = pd . concat ( ( hm_df , aw_df ) , axis = 1 ) . fillna ( 0 ) return sparse_df
TODO: Docstring for get_sparse_lineups.

    :param df: TODO
    :returns: TODO
TODO : Docstring for get_sparse_lineups .