)
  * [ Resampling ](../resampling.html)
  * [ Style ](../style.html)
  * [ Plotting ](../plotting.html)
  * [ Options and settings ](../options.html)
  * [ Extensions ](../extensions.html)
  * [ Testing ](../testing.html)
  * [ Missing values ](../missing_value.html)

  * [ __ ](../../index.html)
  * [ API reference ](../index.html)
  * [ DataFrame ](../frame.html)
  * pandas.DataF... 

#  pandas.DataFrame.from_records  #

_ classmethod  _ DataFrame.  from_records  (  _ data  _ , _ index  =  None  _
, _ exclude  =  None  _ , _ columns  =  None  _ , _ coerce_float  =  False  _
, _ nrows  =  None  _ )  [ [source]  ](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/frame.py#L2318-L2544) #

    

Convert structured or record ndarray to DataFrame.

Creates a DataFrame object from a structured ndarray, sequence of tuples or
dicts, or DataFrame.

Parameters  :

    

**data** structured ndarray, sequence of tuples or dicts, or DataFrame

    

Structured input data.

Deprecated since version 2.1.0:  Passing a DataFrame is deprecated.

**index** str, 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** bool, 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

    

See also

[ ` DataFrame.from_dict  `
](pandas.DataFrame.from_dict.html#pandas.DataFrame.from_dict
"pandas.DataFrame.from_dict")

    

DataFrame from dict of array-like or dicts.

[ ` DataFrame  ` ](pandas.DataFrame.html#pandas.DataFrame "pandas.DataFrame")

    

DataFrame object creation using constructor.

Examples

Data can be provided as a structured ndarray:

    
    
    >>> data = np.array([(3, 'a'), (2, 'b'), (1, 'c'), (0, 'd')],
    ...                 dtype=[('col_1', 'i4'), ('col_2', 'U1')])
    >>> pd.DataFrame.from_records(data)
       col_1 col_2
    0      3     a
    1      2     b
    2      1     c
    3      0     d
    

Data can be provided as a list of dicts:

    
    
    >>> data = [{'col_1': 3, 'col_2': 'a'},
    ...         {'col_1': 2, 'col_2': 'b'},
    ...         {'col_1': 1, 'col_2': 'c'},
    ...         {'col_1': 0, 'col_2': 'd'}]
    >>> pd.DataFrame.from_records(data)
       col_1 col_2
    0      3     a
    1      2     b
    2      1     c
    3      0     d
    

Data can be provided as a list of tuples with corresponding columns:

    
    
    >>> data = [(3, 'a'), (2, 'b'), (1, 'c'), (0, 'd')]
    >>> pd.DataFrame.from_records(data, columns=['col_1', 'col_2'])
       col_1 col_2
    0      3     a
    1      2     b
    2      1     c
    3      0     d
    

[ __ previous  pandas.DataFrame.from_dict  ](pandas.DataFrame.from_dict.html
"previous page") [ next  pandas.DataFrame.to_hdf  __
](pandas.DataFrame.to_hdf.html "next page")

__ On this page

  * ` DataFrame.from_records()  `

[ __ Show Source
](../../_sources/reference/api/pandas.DataFrame.from_records.rst.txt)

© 2024, pandas via [ NumFOCUS, Inc. ](https://numfocus.org) Hosted by [
OVHcloud ](https://www.ovhcloud.com) .

Created using [ Sphinx ](https://www.sphinx-doc.org/) 7.2.6.  

Built with the [ PyData Sphinx Theme ](https://pydata-sphinx-
theme.readthedocs.io/en/stable/index.html) 0.14.4.