def coerce_to_dtypes(result, dtypes):
if len(result) != len(dtypes):<EOL><INDENT>raise AssertionError("<STR_LIT>")<EOL><DEDENT>def conv(r, dtype):<EOL><INDENT>try:<EOL><INDENT>if isna(r):<EOL><INDENT>pass<EOL><DEDENT>elif dtype == _NS_DTYPE:<EOL><INDENT>r = tslibs.Timestamp(r)<EOL><DEDENT>elif dtype == _TD_DTYPE:<EOL><INDENT>r = tslibs.Timedelta(r)<EOL><DEDENT>elif dtype == np.bool_:<EOL><INDENT>if is_integer(r) and r not in [<NUM_LIT:0>, <NUM_LIT:1>]:<EOL><INDENT>return int(r)<EOL><DEDENT>r = bool(r)<EOL><DEDENT>elif dtype.kind == '<STR_LIT:f>':<EOL><INDENT>r = float(r)<EOL><DEDENT>elif dtype.kind == '<STR_LIT:i>':<EOL><INDENT>r = int(r)<EOL><DEDENT><DEDENT>except Exception:<EOL><INDENT>pass<EOL><DEDENT>return r<EOL><DEDENT>return [conv(r, dtype) for r, dtype in zip(result, dtypes)]<EOL>
given a dtypes and a result set, coerce the result elements to the
dtypes