python下的Pandas中DataFrame基本操作(一),基本函数整理

更新时间:2023-07-06 23:54:55 阅读: 评论:0

python下的Pandas中DataFrame基本操作(⼀),基本函数整理
简介
pandas作者Wes McKinney 在【PYTHON FOR DATA ANALYSIS】中对pandas的⽅⽅⾯⾯都有了⼀个权威简明的⼊门级的介绍,但在实际使⽤过程中,我发现书中的内容还只是冰⼭⼀⾓。谈到pandas数据的⾏更新、表合并等操作,⼀般⽤到的⽅法有concat、join、merge。但这三种⽅法对于很多新⼿来说,都不太好分清使⽤的场合与⽤途。
构造函数
⽅法描述
DataFrame([data, index, columns, dtype, copy])构造数据框
属性和数据
⽅法描述
Axes index: row labels;columns: column labels
DataFrame.as_matrix([columns])转换为矩阵
DataFrame.dtypes返回数据的类型
DataFrame.ftypes Return the ftypes (indication of spar/den and dtype) in this object.
<_dtype_counts()返回数据框数据类型的个数
<_ftype_counts()Return the counts of ftypes in this object.
DataFrame.lect_dtypes([include, exclude])根据数据类型选取⼦数据框
DataFrame.values Numpy的展⽰⽅式
DataFrame.axes返回横纵坐标的标签名
DataFrame.ndim返回数据框的纬度
DataFrame.size返回数据框元素的个数
DataFrame.shape返回数据框的形状
<_usage([index, deep])Memory usage of DataFrame columns.
类型转换
点灯的人⽅法描述
DataFrame.astype(dtype[, copy, errors])转换数据类型
DataFrame.isnull()以布尔的⽅式返回空值
索引和迭代
⽅法描述
DataFrame.head([n])返回前n⾏数据
DataFrame.at快速标签常量访问器
DataFrame.iat快速整型常量访问器
DataFrame.loc标签定位
DataFrame.iloc整型定位
阳台种植蔬菜
DataFrame.inrt(loc, column,
value[, …])
在特殊地点插⼊⾏
DataFrame.iter()Iterate over infor axis
DataFrame.iteritems()返回列名和序列的迭代器
DataFrame.iterrows()返回索引和序列的迭代器
DataFrame.itertuples([index,
name])
Iterate over DataFrame rows as namedtuples, with index value as first element of the tuple.
DataFrame.lookup(row_labels,
col_labels)
Label-bad “fancy indexing” function for DataFrame.
DataFrame.pop(item)返回删除的项⽬
DataFrame.tail([n])返回最后n⾏
DataFrame.xs(key[, axis, level,
drop_level])
Returns a cross-ction (row(s) or column(s)) from the Series/DataFrame.
DataFrame.isin(values)是否包含数据框中的元素
DataFrame.where(cond[, other,
广雅实验学校
inplace, …])
条件筛选
DataFrame.mask(cond[, other, inplace, axis, …])Return an object of same shape as lf and who corresponding entries are from lf where cond
is Fal and otherwi are from other.
DataFrame.query(expr[, inplace])Query the columns of a frame with a boolean expression.
⽅法描述
⼆元运算
⽅法描述DataFrame.add(other[, axis, level, fill_value])加法,元素指向
DataFrame.sub(other[, axis, level, fill_value])减法,元素指向
DataFrame.mul(other[, axis, level, fill_value])乘法,元素指向
DataFrame.div(other[, axis, level, fill_value])⼩数除法,元素指向
DataFrame.floordiv(other[, axis, level, …])向下取整除法,元素指向d(other[, axis, level, fill_value])模运算,元素指向
DataFrame.pow(other[, axis, level, fill_value])幂运算,元素指向
DataFrame.radd(other[, axis, level, fill_value])右侧加法,元素指向
DataFrame.rsub(other[, axis, level, fill_value])右侧减法,元素指向
DataFrame.rdiv(other[, axis, level, fill_value])右侧⼩数除法,元素指向
DataFrame.rfloordiv(other[, axis, level, …])右侧向下取整除法,元素指向d(other[, axis, level, fill_value])右侧模运算,元素指向
DataFrame.rpow(other[, axis, level, fill_value])右侧幂运算,元素指向
DataFrame.lt(other[, axis, level])类似Array.lt
<(other[, axis, level])类似
DataFrame.le(other[, axis, level])类似Array.le
<(other[, axis, level])类似
<(other[, axis, level])类似
DataFrame.eq(other[, axis, level])类似Array.eq
…])
Add two DataFrame objects and do not propagate NaN values, so if for a
method.
⽅法描述
函数应⽤&分组&窗⼝
⽅法描述
应⽤函数
给孩子的成长寄语DataFrame.applymap(func)Apply a function to a DataFrame that is intended to operate elementwi, i.e.
DataFrame.aggregate(func[, axis])Aggregate using callable, string, dict, or list of string/ansform(func, *args, **kwargs)Call function producing a like-indexed upby([by, axis, level, …])分组
DataFrame.ewm([com, span, halflife, alpha, …])指数权重窗⼝
描述统计学
⽅法描述
DataFrame.abs()返回绝对值
DataFrame.all([axis, bool_only, skipna, level])Return whether all elements are True over requested axis
DataFrame.any([axis, bool_only, skipna, level])Return whether any element is True over requested axis DataFrame.clip([lower, upper, axis])Trim values at input threshold(s).大喜过望的近义词
DataFrame.clip_lower(threshold[, axis])Return copy of the input with values below given value(s) truncated.
DataFrame.clip_upper(threshold[, axis])Return copy of input with values above given value(s) truncated.
<([method, min_periods])返回本数据框成对列的相关性系数
DataFrame.cummax([axis, skipna])Return cumulative max over requested axis.
DataFrame.cummin([axis, skipna])Return cumulative minimum over requested axis.
DataFrame.cumprod([axis, skipna])返回累积
⽅法描述
DataFrame.cumsum([axis, skipna])返回累和
DataFrame.describe([percentiles, include, …])整体描述数据框
DataFrame.diff([periods, axis])1st discrete difference of object
DataFrame.eval(expr[, inplace])Evaluate an expression in the context of the calling DataFrame instance.
DataFrame.kurt([axis, skipna, level, …])返回⽆偏峰度Fisher’s (kurtosis of normal == 0.0).
DataFrame.mad([axis, skipna, level])返回偏差
DataFrame.max([axis, skipna, level, …])返回最⼤值
DataFrame.min([axis, skipna, level, …])返回最⼩值
DataFrame.pct_change([periods, fill_method, …])返回百分⽐变化
DataFrame.prod([axis, skipna, level, …])返回连乘积
DataFrame.quantile([q, axis, numeric_only, …])返回分位数
DataFrame.rank([axis, method, numeric_only, …])返回数字的排序
2尺8是多少厘米
DataFrame.m([axis, skipna, level, ddof, …])返回⽆偏标准误
DataFrame.skew([axis, skipna, level, …])返回⽆偏偏度
DataFrame.sum([axis, skipna, level, …])求和
DataFrame.std([axis, skipna, level, ddof, …])返回标准误差
DataFrame.var([axis, skipna, level, ddof, …])返回⽆偏误差
从新索引&选取&标签操作
⽅法描述
DataFrame.add_prefix(prefix)添加前缀
DataFrame.add_suffix(suffix)添加后缀
DataFrame.align(other[, join, axis,
Align two object on their axes with the
level, …])
DataFrame.drop(labels[, axis,
返回删除的列
level, …])
Return DataFrame with duplicate rows removed, optionally only
Return boolean Series denoting duplicate rows, optionally only DataFrame.equals(other)两个数据框是否相同
DataFrame.filter([items, like,
过滤特定的⼦数据框
regex, axis])
DataFrame.first(offt)Convenience method for subtting initial periods of time ries data bad on a date offt.
DataFrame.head([n])返回前n⾏
DataFrame.idxmax([axis, skipna])Return index of first occurrence of maximum over requested axis.
DataFrame.idxmin([axis, skipna])Return index of first occurrence of minimum over requested axis.
DataFrame.last(offt)Convenience method for subtting final periods of time ries data bad on a date offt.
Conform DataFrame to new index with optional filling logic, placing NA/NaN in locations having no
value in the previous index.
Conform input object to new index with optional filling logic, placing NA/NaN in locations having no
value in the previous index.
Return an object with matching indices to mylf.
Alter axes input function or functions.
axis, copy, …])
Alter index and / or columns using input function or functions.
For DataFrame with multi-level index, return new DataFrame with labeling information in the columns
under the index names, defaulting to ‘level_0’, ‘level_1’, etc.
DataFrame.sample([n, frac,
replace, …])
返回随机抽样
DataFrame.lect(crit[, axis])Return data corresponding to axis labels matching criteria
Set the DataFrame index (row labels) using one or more existing columns.
DataFrame.tail([n])返回最后⼏⾏
DataFrame.take(indices[, axis,
convert, is_copy])
Analogous to ndarray.take
⽅法描述
处理缺失值
⽅法描述
Return object with labels on given axis omitted where alternately any
填充空值
Replace values given in ‘to_replace’ with ‘value’.
房颤的危害
人物简笔画女孩从新定型&排序&转变形态
⽅法描述
DataFrame.pivot([index,
columns, values])
Reshape data (produce a “pivot” table) bad on column values.
axis])
Rearrange index levels using input order.
Sort by the values along either axis
Sort object by labels (along an axis)
Get the rows of a DataFrame sorted by the n largest values of columns.
Get the rows of a DataFrame sorted by the n smallest values of columns.
DataFrame.swaplevel([i, j, axis])Swap levels i and j in a MultiIndex on a particular axis
DataFrame.stack([level, dropna])Pivot a level of the (possibly hierarchical) column labels, returning a DataFrame (or Series in the ca of an object with a single level of column labels) having a hierarchical index with a new inner-most

本文发布于:2023-07-06 23:54:55,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/89/1070885.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:返回   数据   元素   指向   标签   添加
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图