python-Pandas中DataFrame基本函数python--Pandas中DataFrame基本函数(略全)
pandas⾥的dataframe数据结构常⽤函数。
⽅法描述
DataFrame([data, index, columns, dtype, copy])构造数据框
⽅法描述
Axesindex: row labels;columns: column labels
DataFrame.as_matrix([columns])转换为矩阵
DataFrame.dtypes返回数据的类型
DataFrame.ftypesReturn the ftypes (indication of sparse/dense and dtype) in this object.
<_dtype_counts()返回数据框数据类型的个数
<_ftype_counts()Return the counts of ftypes in this object.
DataFrame.select_dtypes([include, exclude])根据数据类型选取⼦数据框
DataFrame.valuesNumpy的展⽰⽅式
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.insert(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-based “fancy indexing” function for DataFrame.
DataFrame.pop(item)返回删除的项⽬
DataFrame.tail([n])返回最后n⾏
DataFrame.xs(key[, axis, level, drop_level])Returns a cross-section (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 self and whose corresponding entries are from self where cond is False and otherwise 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, …])向下取整除法,元素指向
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])右侧⼩数除法,元素指向
python round函数怎么使用DataFrame.rfloordiv(other[, axis, level, …])右侧向下取整除法,元素指向
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
DataFramebine(other, func[, fill_value, …])Add two DataFrame objects and do not propagate NaN
values, so if for a DataFramebine_first(other)Combine two DataFrame objects and default to non-null values in frame calling the method.
⽅法描述
应⽤函数
DataFrame.applymap(func)Apply a function to a DataFrame that is intended to operate elementwise, i.e.
DataFrame.aggregate(func[, axis])Aggregate using callable, string, dict, or list of string/callables
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, …])返回数字的排序
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, level, …])Align two object on their axes with the
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(offset)Convenience method for subsetting initial periods of time series data based on a date offset.
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(offset)Convenience method for subsetting final periods of time series data based on a date offset.
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 myself.
Alter axes 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.select(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) based on column values.
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 case of an object with a single level of column labels) having a hierarchical index with a new inner-most level of row labels.
DataFrame.unstack([level, fill_value])Pivot a level of the (necessarily hierarchical) index labels, returning a DataFrame having a new level of column labels whose inner-most level consists of the pivoted index labels.
DataFrame.TTranspose index and columns
<_panel()Transform long (stacked) format (DataFrame) into wide (3D, Panel) format.
<_xarray()Return an xarray object from the pandas object.
⽅法描述
追加数据
DataFrame.assign(**kwargs)Assign new columns to a DataFrame, returning a new object (a copy) with all the original columns in addition to the new ones.
DataFrame.join(other[, on, how, lsuffix, …])Join columns with other DataFrame either on index or on a key column.
<(right[, how, on, left_on, …])Merge DataFrame objects by performing a database-style join operation by columns or indexes.
DataFrame.update(other[, join, overwrite, …])Modify DataFrame in place using non-NA values from passed DataFrame.
⽅法描述
DataFrame.asfreq(freq[, method, how, …])将时间序列转换为特定的频次
DataFrame.asof(where[, subset])The last row without any NaN is taken (or the last row without
DataFrame.shift([periods, freq, axis])Shift index by desired number of periods with an optional time freq
DataFrame.first_valid_index()Return label for first non-NA/null value
DataFrame.last_valid_index()Return label for last non-NA/null value
ng of time series. _period([freq, axis, copy])Convert DataFrame from DatetimeIndex to PeriodIndex with desired
<_timestamp([freq, how, axis, copy])Cast to DatetimeIndex of timestamps, at beginning of period
<_convert(tz[, axis, level, copy])Convert tz-aware axis to target time zone.
<_localize(tz[, axis, level, …])Localize tz-naive TimeSeries to target time zone.
⽅法描述
DataFrame plotting accessor and method
DataFrame.plot.area([x, y])⾯积图Area plot
DataFrame.plot.bar([x, y])垂直条形图Vertical bar plot
DataFrame.plot.barh([x, y])⽔平条形图Horizontal bar plot
DataFrame.plot.box([by])箱图Boxplot
DataFrame.plot.density(**kwds)核密度Kernel Density Estimate plot
DataFrame.plot.hexbin(x, y[, C, …])Hexbin plot
DataFrame.plot.hist([by, bins])直⽅图Histogram
DataFrame.plot.kde(**kwds)核密度Kernel Density Estimate plot
DataFrame.plot.line([x, y])线图Line plot
DataFrame.plot.pie([y])饼图Pie chart
DataFrame.plot.scatter(x, y[, s, c])散点图Scatter plot
DataFrame.boxplot([column, by, ax, …])Make a box plot from DataFrame column optionally grouped by some columns or
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论