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
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
TTranspose index and columns atFast label-based scalar accessor axesReturn a list with the row axis labels and column axis labels as the only members. blocksInternal property, property synonym for as_blocks() dtypesReturn the dtypes in this object emptyTrue if NDFrame is entirely empty [no items] ftypesReturn the ftypes (indication of sparse/dense and dtype) in this object. iatFast integer location scalar accessor. ilocPurely integer-location based indexing for selection by position. is_copyixA primarily label-location based indexer, with integer position fallback. locPurely label-location based indexer for selection by label. ndimNumber of axes / array dimensions shapeReturn a tuple representing the dimensionality of the DataFrame. sizenumber of elements in the NDFrame styleProperty returning a Styler object containing methods for building a styled HTML representation fo the DataFrame. valuesNumpy representation of NDFrame Methods