@classmethod<EOL><INDENT>def from_records(cls, data, index=None, exclude=None, columns=None,<EOL>coerce_float=False, nrows=None):<DEDENT>
<EOL>if columns is not None:<EOL><INDENT>columns = ensure_index(columns)<EOL><DEDENT>if is_iterator(data):<EOL><INDENT>if nrows == <NUM_LIT:0>:<EOL><INDENT>return cls()<EOL><DEDENT>try:<EOL><INDENT>first_row = next(data)<EOL><DEDENT>except StopIteration:<EOL><INDENT>return cls(index=index, columns=columns)<EOL><DEDENT>dtype = None<EOL>if hasattr(first_row, '<STR_LIT>') and first_row.dtype.names:<EOL><INDENT>dtype = first_row.dtype<EOL><DEDENT>values = [first_row]<EOL>if nrows is None:<EOL><INDENT>values += data<EOL><DEDENT>else:<EOL><INDENT>values.extend(itertools.islice(data, nrows - <NUM_LIT:1>))<EOL><DEDENT>if dtype is not None:<EOL><INDENT>data = np.array(values, dtype=dtype)<EOL><DEDENT>else:<EOL><INDENT>data = values<EOL><DEDENT><DEDENT>if isinstance(data, dict):<EOL><INDENT>if columns is None:<EOL><INDENT>columns = arr_columns = ensure_index(sorted(data))<EOL>arrays = [data[k] for k in columns]<EOL><DEDENT>else:<EOL><INDENT>arrays = []<EOL>arr_columns = []<EOL>for k, v in data.items():<EOL><INDENT>if k in columns:<EOL><INDENT>arr_columns.append(k)<EOL>arrays.append(v)<EOL><DEDENT><DEDENT>arrays, arr_columns = reorder_arrays(arrays, arr_columns,<EOL>columns)<EOL><DEDENT><DEDENT>elif isinstance(data, (np.ndarray, DataFrame)):<EOL><INDENT>arrays, columns = to_arrays(data, columns)<EOL>if columns is not None:<EOL><INDENT>columns = ensure_index(columns)<EOL><DEDENT>arr_columns = columns<EOL><DEDENT>else:<EOL><INDENT>arrays, arr_columns = to_arrays(data, columns,<EOL>coerce_float=coerce_float)<EOL>arr_columns = ensure_index(arr_columns)<EOL>if columns is not None:<EOL><INDENT>columns = ensure_index(columns)<EOL><DEDENT>else:<EOL><INDENT>columns = arr_columns<EOL><DEDENT><DEDENT>if exclude is None:<EOL><INDENT>exclude = set()<EOL><DEDENT>else:<EOL><INDENT>exclude = set(exclude)<EOL><DEDENT>result_index = None<EOL>if index is not None:<EOL><INDENT>if (isinstance(index, str) or<EOL>not hasattr(index, "<STR_LIT>")):<EOL><INDENT>i = columns.get_loc(index)<EOL>exclude.add(index)<EOL>if len(arrays) > <NUM_LIT:0>:<EOL><INDENT>result_index = Index(arrays[i], name=index)<EOL><DEDENT>else:<EOL><INDENT>result_index = Index([], name=index)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>index_data = [arrays[arr_columns.get_loc(field)]<EOL>for field in index]<EOL>result_index = ensure_index_from_sequences(index_data,<EOL>names=index)<EOL>exclude.update(index)<EOL><DEDENT>except Exception:<EOL><INDENT>result_index = index<EOL><DEDENT><DEDENT><DEDENT>if any(exclude):<EOL><INDENT>arr_exclude = [x for x in exclude if x in arr_columns]<EOL>to_remove = [arr_columns.get_loc(col) for col in arr_exclude]<EOL>arrays = [v for i, v in enumerate(arrays) if i not in to_remove]<EOL>arr_columns = arr_columns.drop(arr_exclude)<EOL>columns = columns.drop(exclude)<EOL><DEDENT>mgr = arrays_to_mgr(arrays, arr_columns, result_index, columns)<EOL>return cls(mgr)<EOL>
Convert structured or record ndarray to DataFrame.

Parameters
----------
data : ndarray (structured dtype), list of tuples, dict, or DataFrame
index : string, list of fields, array-like
    Field of array to use as the index, alternately a specific set of
    input labels to use
exclude : sequence, default None
    Columns or fields to exclude
columns : sequence, default None
    Column names to use. If the passed data do not have names
    associated with them, this argument provides names for the
    columns. Otherwise this argument indicates the order of the columns
    in the result (any names not found in the data will become all-NA
    columns)
coerce_float : boolean, default False
    Attempt to convert values of non-string, non-numeric objects (like
    decimal.Decimal) to floating point, useful for SQL result sets
nrows : int, default None
    Number of rows to read if data is an iterator

Returns
-------
DataFrame