def get_sector_exposures(positions, symbol_sector_map):
cash = positions['<STR_LIT>']<EOL>positions = positions.drop('<STR_LIT>', axis=<NUM_LIT:1>)<EOL>unmapped_pos = np.setdiff1d(positions.columns.values,<EOL>list(symbol_sector_map.keys()))<EOL>if len(unmapped_pos) > <NUM_LIT:0>:<EOL><INDENT>warn_message = """<STR_LIT>""".format(<EOL>"<STR_LIT:U+002CU+0020>".join(map(str, unmapped_pos)))<EOL>warnings.warn(warn_message, UserWarning)<EOL><DEDENT>sector_exp = positions.groupby(<EOL>by=symbol_sector_map, axis=<NUM_LIT:1>).sum()<EOL>sector_exp['<STR_LIT>'] = cash<EOL>return sector_exp<EOL>
Sum position exposures by sector.

Parameters
----------
positions : pd.DataFrame
    Contains position values or amounts.
    - Example
        index         'AAPL'         'MSFT'        'CHK'        cash
        2004-01-09    13939.380     -15012.993    -403.870      1477.483
        2004-01-12    14492.630     -18624.870    142.630       3989.610
        2004-01-13    -13853.280    13653.640     -100.980      100.000
symbol_sector_map : dict or pd.Series
    Security identifier to sector mapping.
    Security ids as keys/index, sectors as values.
    - Example:
        {'AAPL' : 'Technology'
         'MSFT' : 'Technology'
         'CHK' : 'Natural Resources'}

Returns
-------
sector_exp : pd.DataFrame
    Sectors and their allocations.
    - Example:
        index         'Technology'    'Natural Resources' cash
        2004-01-09    -1073.613       -403.870            1477.4830
        2004-01-12    -4132.240       142.630             3989.6100
        2004-01-13    -199.640        -100.980            100.0000