def data_to_naics_opp_counts(opp_naics_df):
    """
    Takes the NAICS_Opportunity dataframe and gets the total opportunity count by NAICS code.
    """
    filtered_df = opp_naics_df[~opp_naics_df['Opportunity__r.Account.Name'].isin([
        'Water & Power', 
        'Airports, Los Angeles World', 
        'Harbor Department, Port of Los Angeles'
    ])]
    return (
        filtered_df
        .groupby(['NAICS_Code__r.Name'])
        .count()
        .sort_values(by='Opportunity__r.Id', ascending=False)
        .reset_index()
        [['NAICS_Code__r.Name', 'Opportunity__r.Id']]
        .rename(columns={
            'NAICS_Code__r.Name': 'Opportunity_NAICS',
            'Opportunity__r.Id': 'Number of Opportunities'
        })
    )