api/views.py
def update_fields(df: DataFrame, single_game: bool = False) -> DataFrame:
    """Convert pct fields from 0.xxx to xx.x format and update certain keys
    names to display names.
    """
    # Update percentage fields
    keys = [
        'FG_PCT', 'FG3_PCT', 'FT_PCT', 'WIN_PCT', 'WinPCT', 'W_PCT', 'PCT'
    ]
    result = df.copy()
    for key in keys:
        if key in df.keys():
            try:
                if result[key][0] is not None:
                    result[key] = round(100 * result[key], 1)
            except (IndexError, ValueError):
                result[key] = round(100 * result[key], 1)

    # Change team id type to string
    team_id_keys = ['TEAM_ID', 'TeamID']
    for key in team_id_keys:
        if key in df.keys():
            result[key] = result[key].astype(str)

    # Update single game stat fields if enabled
    if single_game:
        clean_single_game_data(result)

    # Rename fields for display purpose
    mapping = {
        'PLUS_MINUS': '+/-',
        'FG_PCT': 'FG%',
        'FG3_PCT': 'FG3%',
        'FT_PCT': 'FT%',
        'WIN_PCT': 'WIN%',
        'W_PCT': 'WIN%',
        'START_POSITION': 'P'
    }
    for key, value in mapping.items():
        if key in df.keys():
            result.rename({key: value}, axis=1, inplace=True)

    return result
Convert pct fields from 0.xxx to xx.x format and update certain keys
    names to display names.
    
Convert pct fields from 0.xxx to xx.x format and update certain keys
names to display names.
Convert pct fields from 0 . xxx to xx . x format and update certain keys names to display names .
def update_fields(df: DataFrame, single_game: bool = False) -> DataFrame:
    keys = [
        'FG_PCT', 'FG3_PCT', 'FT_PCT', 'WIN_PCT', 'WinPCT', 'W_PCT', 'PCT'
    ]
    result = df.copy()
    for key in keys:
        if key in df.keys():
            try:
                if result[key][0] is not None:
                    result[key] = round(100 * result[key], 1)
            except (IndexError, ValueError):
                result[key] = round(100 * result[key], 1)
    team_id_keys = ['TEAM_ID', 'TeamID']
    for key in team_id_keys:
        if key in df.keys():
            result[key] = result[key].astype(str)
    if single_game:
        clean_single_game_data(result)
    mapping = {
        'PLUS_MINUS': '+/-',
        'FG_PCT': 'FG%',
        'FG3_PCT': 'FG3%',
        'FT_PCT': 'FT%',
        'WIN_PCT': 'WIN%',
        'W_PCT': 'WIN%',
        'START_POSITION': 'P'
    }
    for key, value in mapping.items():
        if key in df.keys():
            result.rename({key: value}, axis=1, inplace=True)
    return result
def update_fields ( df : DataFrame , single_game : bool = False ) -> DataFrame : keys = [ 'FG_PCT' , 'FG3_PCT' , 'FT_PCT' , 'WIN_PCT' , 'WinPCT' , 'W_PCT' , 'PCT' ] result = df . copy ( ) for key in keys : if key in df . keys ( ) : try : if result [ key ] [ 0 ] is not None : result [ key ] = round ( 100 * result [ key ] , 1 ) except ( IndexError , ValueError ) : result [ key ] = round ( 100 * result [ key ] , 1 ) team_id_keys = [ 'TEAM_ID' , 'TeamID' ] for key in team_id_keys : if key in df . keys ( ) : result [ key ] = result [ key ] . astype ( str ) if single_game : clean_single_game_data ( result ) mapping = { 'PLUS_MINUS' : '+/-' , 'FG_PCT' : 'FG%' , 'FG3_PCT' : 'FG3%' , 'FT_PCT' : 'FT%' , 'WIN_PCT' : 'WIN%' , 'W_PCT' : 'WIN%' , 'START_POSITION' : 'P' } for key , value in mapping . items ( ) : if key in df . keys ( ) : result . rename ( { key : value } , axis = 1 , inplace = True ) return result
Convert pct fields from 0.xxx to xx.x format and update certain keys
names to display names.
Convert pct fields from 0 . xxx to xx . x format and update certain keys names to display names .
"""Convert pct fields from 0.xxx to xx.x format and update certain keys
    names to display names.
    """ # Update percentage fields # Change team id type to string # Update single game stat fields if enabled # Rename fields for display purpose
df
DataFrame
single_game
bool