Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Module « pandas »

Classe « DataFrame »

Informations générales

Héritage

        builtins.object
            OpsMixin
    builtins.object
        IndexingMixin
    builtins.object
        SelectionMixin
builtins.object
    DirNamesMixin
        PandasObject
            NDFrame
                DataFrame

Définition

class DataFrame(NDFrame, OpsMixin):

Description [extrait de DataFrame.__doc__]

    Two-dimensional, size-mutable, potentially heterogeneous tabular data.

    Data structure also contains 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 : ndarray (structured or homogeneous), Iterable, dict, or DataFrame
        Dict can contain Series, arrays, constants, dataclass or list-like objects. If
        data is a dict, column order follows insertion-order.

        .. versionchanged:: 0.25.0
           If data is a list of dicts, column order follows insertion-order.

    index : Index or array-like
        Index to use for resulting frame. Will default to RangeIndex 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
        RangeIndex (0, 1, 2, ..., n) if no column labels are provided.
    dtype : dtype, default None
        Data type to force. Only a single dtype is allowed. If None, infer.
    copy : bool, 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.
    read_csv : Read a comma-separated values (csv) file into DataFrame.
    read_table : Read general delimited file into DataFrame.
    read_clipboard : Read text from clipboard into DataFrame.

    Examples
    --------
    Constructing DataFrame from a dictionary.

    >>> d = {'col1': [1, 2], 'col2': [3, 4]}
    >>> df = pd.DataFrame(data=d)
    >>> df
       col1  col2
    0     1     3
    1     2     4

    Notice that the inferred dtype is int64.

    >>> df.dtypes
    col1    int64
    col2    int64
    dtype: object

    To enforce a single dtype:

    >>> df = pd.DataFrame(data=d, dtype=np.int8)
    >>> df.dtypes
    col1    int8
    col2    int8
    dtype: object

    Constructing DataFrame from numpy ndarray:

    >>> df2 = pd.DataFrame(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]),
    ...                    columns=['a', 'b', 'c'])
    >>> df2
       a  b  c
    0  1  2  3
    1  4  5  6
    2  7  8  9

    Constructing DataFrame from dataclass:

    >>> from dataclasses import make_dataclass
    >>> Point = make_dataclass("Point", [("x", int), ("y", int)])
    >>> pd.DataFrame([Point(0, 0), Point(0, 3), Point(2, 3)])
        x  y
    0  0  0
    1  0  3
    2  2  3
    

Constructeur(s)

Signature du constructeur Description
__init__(self, data=None, index: 'Optional[Axes]' = None, columns: 'Optional[Axes]' = None, dtype: 'Optional[Dtype]' = None, copy: 'bool' = False)

Liste des attributs statiques

Nom de l'attribut Valeur
columns<pandas._libs.properties.AxisProperty object at 0x7f504a7c9670>
index<pandas._libs.properties.AxisProperty object at 0x7f504a7c9520>

Attributs statiques hérités de la classe SelectionMixin

ndim

Liste des propriétés

Nom de la propriétéDescription
at
attrs
axes
dtypes
empty
flags
iat
iloc
loc
ndim
shape
size
style
T
values

Liste des opérateurs

Signature de l'opérateur Description
__getitem__(self, key)
__matmul__(self, other)
__setitem__(self, key, value)

Opérateurs hérités de la classe OpsMixin

__add__, __and__, __eq__, __floordiv__, __ge__, __gt__, __le__, __lt__, __mod__, __mul__, __ne__, __or__, __pow__, __radd__, __rand__, __rfloordiv__, __rmod__, __rmul__, __ror__, __rpow__, __rsub__, __rtruediv__, __rxor__, __sub__, __truediv__, __xor__

Opérateurs hérités de la classe NDFrame

__contains__, __delitem__, __iadd__, __iand__, __ifloordiv__, __imod__, __imul__, __invert__, __ior__, __ipow__, __isub__, __itruediv__, __ixor__, __neg__, __pos__

Liste des méthodes

Toutes les méthodes Méthodes d'instance Méthodes statiques Méthodes dépréciées
Signature de la méthodeDescription
__divmod__(self, other) -> 'Tuple[DataFrame, DataFrame]'
__len__(self) -> 'int'
__rdivmod__(self, other) -> 'Tuple[DataFrame, DataFrame]'
__repr__(self) -> 'str'
__rmatmul__(self, other)
agg(self, func=None, axis=0, *args, **kwargs)
aggregate(self, func=None, axis=0, *args, **kwargs)
align(self, other, join='outer', axis=None, level=None, copy=True, fill_value=None, method=None, limit=None, fill_axis=0, broadcast_axis=None) -> 'DataFrame'
append(self, other, ignore_index=False, verify_integrity=False, sort=False) -> 'DataFrame'
apply(self, func, axis=0, raw=False, result_type=None, args=(), **kwds)
applymap(self, func, na_action: 'Optional[str]' = None) -> 'DataFrame'
assign(self, **kwargs) -> 'DataFrame'
combine(self, other: 'DataFrame', func, fill_value=None, overwrite=True) -> 'DataFrame'
combine_first(self, other: 'DataFrame') -> 'DataFrame'
compare(self, other: 'DataFrame', align_axis: 'Axis' = 1, keep_shape: 'bool' = False, keep_equal: 'bool' = False) -> 'DataFrame'
corr(self, method='pearson', min_periods=1) -> 'DataFrame'
corrwith(self, other, axis=0, drop=False, method='pearson') -> 'Series'
count(self, axis=0, level=None, numeric_only=False)
cov(self, min_periods: 'Optional[int]' = None, ddof: 'Optional[int]' = 1) -> 'DataFrame'
diff(self, periods: 'int' = 1, axis: 'Axis' = 0) -> 'DataFrame'
dot(self, other)
drop(self, labels=None, axis=0, index=None, columns=None, level=None, inplace=False, errors='raise')
drop_duplicates(self, subset: 'Optional[Union[Hashable, Sequence[Hashable]]]' = None, keep: 'Union[str, bool]' = 'first', inplace: 'bool' = False, ignore_index: 'bool' = False) -> 'Optional[DataFrame]'
dropna(self, axis=0, how='any', thresh=None, subset=None, inplace=False)
duplicated(self, subset: 'Optional[Union[Hashable, Sequence[Hashable]]]' = None, keep: 'Union[str, bool]' = 'first') -> 'Series'
eval(self, expr, inplace=False, **kwargs)
explode(self, column: 'Union[str, Tuple]', ignore_index: 'bool' = False) -> 'DataFrame'
fillna(self, value=None, method=None, axis=None, inplace=False, limit=None, downcast=None) -> 'Optional[DataFrame]'
from_dict(data, orient='columns', dtype=None, columns=None) -> 'DataFrame'
from_records(data, index=None, exclude=None, columns=None, coerce_float=False, nrows=None) -> 'DataFrame'
groupby(self, by=None, axis=0, level=None, as_index: 'bool' = True, sort: 'bool' = True, group_keys: 'bool' = True, squeeze: 'bool' = <object object at 0x7f5051439e10>, observed: 'bool' = False, dropna: 'bool' = True) -> 'DataFrameGroupBy'
idxmax(self, axis=0, skipna=True) -> 'Series'
idxmin(self, axis=0, skipna=True) -> 'Series'
info(self, verbose: 'Optional[bool]' = None, buf: 'Optional[IO[str]]' = None, max_cols: 'Optional[int]' = None, memory_usage: 'Optional[Union[bool, str]]' = None, show_counts: 'Optional[bool]' = None, null_counts: 'Optional[bool]' = None) -> 'None'
insert(self, loc, column, value, allow_duplicates=False) -> 'None'
isin(self, values) -> 'DataFrame'
isna(self) -> 'DataFrame'
isnull(self) -> 'DataFrame'
items(self) -> 'Iterable[Tuple[Label, Series]]'
iteritems(self) -> 'Iterable[Tuple[Label, Series]]'
iterrows(self) -> 'Iterable[Tuple[Label, Series]]'
itertuples(self, index: 'bool' = True, name: 'Optional[str]' = 'Pandas')
join(self, other, on=None, how='left', lsuffix='', rsuffix='', sort=False) -> 'DataFrame'
lookup(self, row_labels, col_labels) -> 'np.ndarray'
melt(self, id_vars=None, value_vars=None, var_name=None, value_name='value', col_level=None, ignore_index=True) -> 'DataFrame'
memory_usage(self, index=True, deep=False) -> 'Series'
merge(self, right, how='inner', on=None, left_on=None, right_on=None, left_index=False, right_index=False, sort=False, suffixes=('_x', '_y'), copy=True, indicator=False, validate=None) -> 'DataFrame'
mode(self, axis=0, numeric_only=False, dropna=True) -> 'DataFrame'
nlargest(self, n, columns, keep='first') -> 'DataFrame'
notna(self) -> 'DataFrame'
notnull(self) -> 'DataFrame'
nsmallest(self, n, columns, keep='first') -> 'DataFrame'
nunique(self, axis=0, dropna=True) -> 'Series'
pivot(self, index=None, columns=None, values=None) -> 'DataFrame'
pivot_table(self, values=None, index=None, columns=None, aggfunc='mean', fill_value=None, margins=False, dropna=True, margins_name='All', observed=False) -> 'DataFrame'
pop(self, item: 'Label') -> 'Series'
quantile(self, q=0.5, axis=0, numeric_only=True, interpolation='linear')
query(self, expr, inplace=False, **kwargs)
reindex(self, labels=None, index=None, columns=None, axis=None, method=None, copy=True, level=None, fill_value=nan, limit=None, tolerance=None)
rename(self, mapper=None, index=None, columns=None, axis=None, copy=True, inplace=False, level=None, errors='ignore')
reorder_levels(self, order, axis=0) -> 'DataFrame'
replace(self, to_replace=None, value=None, inplace=False, limit=None, regex=False, method='pad')
reset_index(self, level: 'Optional[Union[Hashable, Sequence[Hashable]]]' = None, drop: 'bool' = False, inplace: 'bool' = False, col_level: 'Hashable' = 0, col_fill: 'Label' = '') -> 'Optional[DataFrame]'
round(self, decimals=0, *args, **kwargs) -> 'DataFrame'
select_dtypes(self, include=None, exclude=None) -> 'DataFrame'
set_axis(self, labels, axis: 'Axis' = 0, inplace: 'bool' = False)
set_index(self, keys, drop=True, append=False, inplace=False, verify_integrity=False)
shift(self, periods=1, freq=None, axis=0, fill_value=<object object at 0x7f5051439e10>) -> 'DataFrame'
sort_index(self, axis=0, level=None, ascending: 'Union[Union[bool, int], Sequence[Union[bool, int]]]' = True, inplace: 'bool' = False, kind: 'str' = 'quicksort', na_position: 'str' = 'last', sort_remaining: 'bool' = True, ignore_index: 'bool' = False, key: 'IndexKeyFunc' = None)
sort_values(self, by, axis=0, ascending=True, inplace=False, kind='quicksort', na_position='last', ignore_index=False, key: 'ValueKeyFunc' = None)
stack(self, level=-1, dropna=True)
swaplevel(self, i=-2, j=-1, axis=0) -> 'DataFrame'
to_dict(self, orient='dict', into=<class 'dict'>)
to_feather(self, path: 'FilePathOrBuffer[AnyStr]', **kwargs) -> 'None'
to_gbq(self, destination_table, project_id=None, chunksize=None, reauth=False, if_exists='fail', auth_local_webserver=False, table_schema=None, location=None, progress_bar=True, credentials=None) -> 'None'
to_html(self, buf=None, columns=None, col_space=None, header=True, index=True, na_rep='NaN', formatters=None, float_format=None, sparsify=None, index_names=True, justify=None, max_rows=None, max_cols=None, show_dimensions=False, decimal='.', bold_rows=True, classes=None, escape=True, notebook=False, border=None, table_id=None, render_links=False, encoding=None)
to_markdown(self, buf: 'Optional[Union[IO[str], str]]' = None, mode: 'str' = 'wt', index: 'bool' = True, storage_options: 'StorageOptions' = None, **kwargs) -> 'Optional[str]'
to_numpy(self, dtype=None, copy: 'bool' = False, na_value=<object object at 0x7f5051439e10>) -> 'np.ndarray'
to_parquet(self, path: 'Optional[FilePathOrBuffer]' = None, engine: 'str' = 'auto', compression: 'Optional[str]' = 'snappy', index: 'Optional[bool]' = None, partition_cols: 'Optional[List[str]]' = None, storage_options: 'StorageOptions' = None, **kwargs) -> 'Optional[bytes]'
to_period(self, freq=None, axis: 'Axis' = 0, copy: 'bool' = True) -> 'DataFrame'
to_records(self, index=True, column_dtypes=None, index_dtypes=None) -> 'np.recarray'
to_stata(self, path: 'FilePathOrBuffer', convert_dates: 'Optional[Dict[Label, str]]' = None, write_index: 'bool' = True, byteorder: 'Optional[str]' = None, time_stamp: 'Optional[datetime.datetime]' = None, data_label: 'Optional[str]' = None, variable_labels: 'Optional[Dict[Label, str]]' = None, version: 'Optional[int]' = 114, convert_strl: 'Optional[Sequence[Label]]' = None, compression: 'CompressionOptions' = 'infer', storage_options: 'StorageOptions' = None) -> 'None'
to_string(self, buf: 'Optional[FilePathOrBuffer[str]]' = None, columns: 'Optional[Sequence[str]]' = None, col_space: 'Optional[int]' = None, header: 'Union[bool, Sequence[str]]' = True, index: 'bool' = True, na_rep: 'str' = 'NaN', formatters: 'Optional[fmt.FormattersType]' = None, float_format: 'Optional[fmt.FloatFormatType]' = None, sparsify: 'Optional[bool]' = None, index_names: 'bool' = True, justify: 'Optional[str]' = None, max_rows: 'Optional[int]' = None, min_rows: 'Optional[int]' = None, max_cols: 'Optional[int]' = None, show_dimensions: 'bool' = False, decimal: 'str' = '.', line_width: 'Optional[int]' = None, max_colwidth: 'Optional[int]' = None, encoding: 'Optional[str]' = None) -> 'Optional[str]'
to_timestamp(self, freq=None, how: 'str' = 'start', axis: 'Axis' = 0, copy: 'bool' = True) -> 'DataFrame'
transform(self, func: 'AggFuncType', axis: 'Axis' = 0, *args, **kwargs) -> 'DataFrame'
transpose(self, *args, copy: 'bool' = False) -> 'DataFrame'
unstack(self, level=-1, fill_value=None)
update(self, other, join='left', overwrite=True, filter_func=None, errors='ignore') -> 'None'
value_counts(self, subset: 'Optional[Sequence[Label]]' = None, normalize: 'bool' = False, sort: 'bool' = True, ascending: 'bool' = False)

Méthodes héritées de la classe OpsMixin

__init_subclass__, __subclasshook__

Méthodes héritées de la classe NDFrame

__abs__, __array__, __array_ufunc__, __array_wrap__, __bool__, __copy__, __deepcopy__, __finalize__, __getattr__, __getstate__, __hash__, __iter__, __nonzero__, __round__, __setattr__, __setstate__, abs, add_prefix, add_suffix, all, any, asfreq, asof, astype, at_time, backfill, between_time, bfill, bool, clip, convert_dtypes, copy, cummax, cummin, cumprod, cumsum, describe, droplevel, equals, ewm, expanding, ffill, filter, first, first_valid_index, get, head, infer_objects, interpolate, keys, kurt, kurtosis, last, last_valid_index, mad, mask, max, mean, median, min, pad, pct_change, pipe, prod, product, rank, reindex_like, rename_axis, resample, rolling, sample, sem, set_flags, skew, slice_shift, squeeze, std, sum, swapaxes, tail, take, to_clipboard, to_csv, to_excel, to_hdf, to_json, to_latex, to_pickle, to_sql, to_xarray, truncate, tshift, tz_convert, tz_localize, var, where, xs

Méthodes héritées de la classe PandasObject

__sizeof__

Méthodes héritées de la classe DirNamesMixin

__dir__

Méthodes héritées de la classe object

__delattr__, __format__, __getattribute__, __reduce__, __reduce_ex__, __str__