def modify_ref_method_str(df, param):
    """Subroutine for Ref_API_Query tha replaces various characters in data
    columns containing text, including the method name and the parameter units.

    Instrument Method names retrieved from the method code lookup table are
    specified in all upper case characters. These are converted to title cased
    characters (e.g., This Is Title Cased Text). While this imrpoves legibility
    some phrases (particularly acronyms, conjunctions, prepositions, ect.)
    should not be title cased. This function replaces specific phrases with the
    expected format.

    In addition, abbreviated unit names (used by AirNow) are converted to
    long format text to ensure consistency for reference data retreived from
    AQS, AirNow, and AirNowTech, and also to improve legibility.

    Args:
        df (pandas DataFrame):
            Dataframe resulting from API query.
        param (str):
            The evaluation parameter.

    Returns:
        df (pandas DataFrame):
            Modified dataframe with method and unit strings corrected.

    """
    # Lookup dictionary of phrases that shouldn't be title cased
    replace = {'Method': {'Api': 'API',
                          'Frm': 'FRM',
                          'Fem': 'FEM',
                          'Lpm': 'LPM',
                          ' At ': ' at ',
                          'Bam': 'BAM',
                          'Pm': 'PM',
                          'Vscc': 'VSCC',
                          'Te': 'TE',
                          ' Or ': ' or ',
                          'W/': 'w/',
                          ' And ': ' and '},
               'Unit': {'PPB': 'Parts per billion',
                        'PPM': 'Parts per million',
                        'UG/M3': 'Micrograms/cubic meter'}
               }

    for attrib in replace:
        for oldstr, newstr in zip(replace[attrib], replace[attrib].values()):
            col = param + '_' + attrib
            df[col] = df[col].astype(str).str.replace(oldstr, newstr)

    return df