#NEWLINE# def find_movers( choosers , rates , rate_column ) : #NEWLINE# #INDENT# '\n    Returns an array of the indexes of the `choosers` that are slated\n    to move.\n\n    Parameters\n    ----------\n    choosers : pandas.DataFrame\n        Table of agents from which to find movers.\n    rates : pandas.DataFrame\n        Table of relocation rates. Index is unused.\n\n        Other columns describe filters on the `choosers`\n        table so that different segments can have different relocation\n        rates. Columns that ends with \'_max\' will be used to create\n        a "less than" filters, columns that end with \'_min\' will be\n        used to create "greater than or equal to" filters.\n        A column with no suffix will be used to make an \'equal to\' filter.\n\n        An example `rates` structure:\n\n        age_of_head_max  age_of_head_min\n                    nan               65\n                     65               40\n\n        In this example the `choosers` table would need to have an\n        \'age_of_head\' column on which to filter.\n\n        nan should be used to flag filters that do not apply\n        in a given row.\n    rate_column : object\n        Name of column in `rates` table that has relocation rates.\n\n    Returns\n    -------\n    movers : pandas.Index\n        Suitable for indexing `choosers` by index.\n\n    ' #NEWLINE# logger . debug ( 'start: find movers for relocation' ) #NEWLINE# relocation_rates = pd . Series ( np . zeros ( len ( choosers ) ) , index = choosers . index ) #NEWLINE# for ( _ , row ) in rates . iterrows ( ) : #NEWLINE# #INDENT# indexes = util . filter_table ( choosers , row , ignore = { rate_column } ) . index #NEWLINE# relocation_rates . loc [ indexes ] = row [ movers ] #NEWLINE# #UNINDENT# movers = relocation_rates . index [ ( relocation_rates > np . random . random ( len ( choosers ) ) ) ] #NEWLINE# logger . debug ( 'picked {} movers for relocation' . format ( len ( movers ) ) ) #NEWLINE# logger . debug ( 'finish: find movers for relocation' ) #NEWLINE# return movers