pandas.DataFrame

class pandas.DataFrame(data=None, index=None, columns=None, dtype=None, copy=False)

Two-dimensional size-mutable, potentially heterogeneous tabular data structure with labeled axes (rows and columns). Arithmetic operations align on both row and column labels. Can be thought of as a dict-like container for Series objects. The primary pandas data structure

Parameters:

data : numpy ndarray (structured or homogeneous), dict, or DataFrame

Dict can contain Series, arrays, constants, or list-like objects

index : Index or array-like

Index to use for resulting frame. Will default to np.arange(n) if no indexing information part of input data and no index provided

columns : Index or array-like

Column labels to use for resulting frame. Will default to np.arange(n) if no column labels are provided

dtype : dtype, default None

Data type to force, otherwise infer

copy : boolean, default False

Copy data from inputs. Only affects DataFrame / 2d ndarray input

See also

DataFrame.from_records
constructor from tuples, also record arrays
DataFrame.from_dict
from dicts of Series, arrays, or dicts
DataFrame.from_items
from sequence of (key, value) pairs

pandas.read_csv, pandas.read_table, pandas.read_clipboard

Examples

>>> d = {'col1': ts1, 'col2': ts2}
>>> df = DataFrame(data=d, index=index)
>>> df2 = DataFrame(np.random.randn(10, 5))
>>> df3 = DataFrame(np.random.randn(10, 5),
...                 columns=['a', 'b', 'c', 'd', 'e'])

Attributes

T Transpose index and columns
at Fast label-based scalar accessor
axes Return a list with the row axis labels and column axis labels as the only members.
blocks Internal property, property synonym for as_blocks()
dtypes Return the dtypes in this object
empty True if NDFrame is entirely empty [no items]
ftypes Return the ftypes (indication of sparse/dense and dtype) in this object.
iat Fast integer location scalar accessor.
iloc Purely integer-location based indexing for selection by position.
is_copy
ix A primarily label-location based indexer, with integer position fallback.
loc Purely label-location based indexer for selection by label.
ndim Number of axes / array dimensions
shape Return a tuple representing the dimensionality of the DataFrame.
size number of elements in the NDFrame
style Property returning a Styler object containing methods for building a styled HTML representation fo the DataFrame.
values Numpy representation of NDFrame

Methods