Pandas手册汉化

目录

输入/输出

Pickling

平面文件

剪贴板

Excel

JSON

HTML

HDFStore: PyTables (HDF5)

Feather

Parquet

SAS

SQL

Google BigQuery

STATA

一般功能

数据处理

顶级缺失数据

顶级转换

顶级处理时间

顶级处理间隔

顶级评估

Series

构造函数

属性

转换

索引, 迭代

二元运算符函数

Function application, GroupBy & Window

计算/ 描述性统计

重新索引/ 选择/ 标签操作

缺少数据处理

重塑, 排序

合并/ 加入

时间序列

类似日期的属性

字符串处理

分类

绘图

序列化/ IO / 转换

Sparse

DataFrame

构造函数

属性和基础数据

转换

索引, 迭代

二元运算符函数

Function application, GroupBy & Window

计算/ 描述性统计

重新索引/ 选择/ 标签操作

缺少数据处理

重塑, 排序, 转置

合并/ 加入

时间序列

绘图

序列化/ IO / 转换

Sparse

面板

Attributes and underlying data

转换

索引, 迭代, 切片

Binary operator functions

Function application, GroupBy

计算/ 描述属性

重新索引/ 选择/ 标签操作

缺少数据处理

重塑, 排序, 转置

合并/ 加入

时间序列相关

序列化/ IO / 转换

索引

属性

缺少值

转换

排序

特定时间的操作

组合/ 加入/ 设置操作

选择

Numeric Index

分类

分类组件

IntervalIndex

IntervalIndex Components

多指标

MultiIndex 构造函数

MultiIndex 属性

MultiIndex 组件

MultiIndex 选择

DatetimeIndex

选择时间/日期组件

选择

特定时间的操作

转换

TimedeltaIndex

ConversionComponents

转换

PeriodIndex

属性

Methods

标量

Period

属性

方法

时间戳

方法

间隔

属性

Timedelta

属性

方法

频率

窗口

标准移动窗口函数

标准扩展窗口函数

指数加权移动窗口函数

GroupBy

索引, 迭代

功能应用

计算/ 描述性统计

重新采样

索引, 迭代

功能应用

上采样

计算/ 描述性统计

Style

Styler 构造函数

Styler 属性

风格应用

内置样式

样式导出和导入

绘图

一般实用功能

使用选项

测试功能

例外 and 警告

数据类型相关功能

扩展


Pandas手册汉化

此页面概述了所有公共pandas对象,函数和方法。pandas.*命名空间中公开的所有类和函数都是公共的。

一些子包是公共的,其中包括pandas.errors, pandas.plotting,和pandas.testing。文档中提到了公共函数 pandas.iopandas.tseries子模块。pandas.api.types分包包含一些与pandas中的数据类型相关的公共函数

输入/输出

Pickling

read_pickle(path[, compression]):从文件加载pickled pandas对象(或任何对象)

平面文件

read_table(filepath_or_buffer[, sep, …]):将常规分隔文件读入DataFrame

read_csv(filepath_or_buffer[, sep, …]):将CSV(逗号分隔)文件读入DataFrame

read_fwf(filepath_or_buffer[, colspecs, widths]):将固定宽度格式化的行表读入DataFrame

read_msgpack(path_or_buf[, encoding, iterator]):从指定的文件路径加载msgpack pandas对象

剪贴板

read_clipboard([sep]):从剪贴板中读取文本并传递给read_table.

Excel

read_excel(io[, sheet_name, header, names, …]):将Excel表读入pandas DataFrame

ExcelFile.parse([sheet_name, header, names, …]):将指定的工作表解析为DataFrame

JSON

read_json([path_or_buf, orient, typ, dtype, …]):将JSON字符串转换为pandas对象

json_normalize(data[, record_path, meta, …]):将“半结构化JSON数据”“规范化”为平面表

build_table_schema(data[, index, …]):从中创建表模式data

HTML

read_html(io[, match, flavor, header, …]):阅读HTML表格到list的DataFrame对象

HDFStore: PyTables (HDF5)

read_hdf(path_or_buf[, key, mode]):从商店读取,如果我们打开它关闭它.

HDFStore.put(key, value[, format, append]):将对象存储在HDFStore中

HDFStore.append(key, value[, format, …]):附加到文件中的表.

HDFStore.get(key):检索存储在文件中的pandas对象

HDFStore.select(key[, where, start, stop, …]):检索存储在文件中的pandas对象,可选择基于where条件

HDFStore.info():打印商店的详细信息

HDFStore.keys():返回与HDFStore中存储的对象相对应的键(可能无序)列表。

Feather

read_feather(path[, nthreads]):从文件路径加载羽毛格式对象

Parquet

read_parquet(path[, engine, columns]):从文件路径加载镶木地板对象,返回DataFrame.

SAS

read_sas(filepath_or_buffer[, format, …]):读取存储为XPORT或SAS7BDAT格式文件的SAS文件

SQL

read_sql_table(table_name, con[, schema, …]):将SQL数据库表读入DataFrame.

read_sql_query(sql, con[, index_col, …]):将SQL查询读入DataFrame.

read_sql(sql, con[, index_col, …]):将SQL查询或数据库表读入DataFrame.

Google BigQuery

read_gbq(query[, project_id, index_col, …]):从Google BigQuery加载数据.

STATA

read_stata(filepath_or_buffer[, …]):将Stata文件读入DataFrame.

StataReader.data_label():返回Stata文件的数据标签

StataReader.value_labels():返回一个dict,将每个变量名称与一个dict相关联,将每个值与其对

StataReader.variable_labels():将变量标签作为dict返回,将每个变量名称与相应的标签相关联

一般功能

数据处理

melt(frame[, id_vars, value_vars, var_name, …]):“Unpivots”DataFrame从宽格式到长格式,可选择设置标识符变量。

pivot(index, columns, values):根据此DataFrame的3列生成“pivot”表。

pivot_table(data[, values, index, columns, …]):创建一个电子表格样式的数据透视表作为DataFrame。

crosstab(index, columns[, values, rownames, …]):计算两个(或更多)因子的简单交叉列表。

cut(x, bins[, right, labels, retbins, …]):Bin值为离散间隔。

qcut(x, q[, labels, retbins, precision, …]):基于分位数的离散化功能。

merge(left, right[, how, on, left_on, …]):通过按列或索引执行数据库样式的连接操作来合并DataFrame对象。

merge_ordered(left, right[, on, left_on, …]):使用为时序数据等有序数据设计的可选填充/插值执行合并。

merge_asof(left, right[, on, left_on, …]):执行asof合并。

concat(objs[, axis, join, join_axes, …]):沿特定轴连接pandas对象,沿其他轴使用可选的设置逻辑。

get_dummies(data[, prefix, prefix_sep, …]):将分类变量转换为虚拟/指示变量

factorize(values[, sort, order, …]):将对象编码为枚举类型或分类变量。

unique(values):哈希表基于唯一。

wide_to_long(df, stubnames, i, j[, sep, suffix]):宽面板到长格式。

顶级缺失数据

isna(obj):检测类似数组的对象的缺失值。

isnull(obj):检测类似数组的对象的缺失值。

notna(obj):检测类似数组的对象的非缺失值。

notnull(obj):检测类似数组的对象的非缺失值。

顶级转换

to_numeric(arg[, errors, downcast]):将参数转换为数字类型.

顶级处理时间

to_datetime(arg[, errors, dayfirst, …]):将参数转换为datetime。

to_timedelta(arg[, unit, box, errors]):将参数转换为timedelta

date_range([start, end, periods, freq, tz, …]):返回固定频率DatetimeIndex。

bdate_range([start, end, periods, freq, tz, …]):返回固定频率DatetimeIndex,以工作日作为默认频率

period_range([start, end, periods, freq, name]):返回固定频率PeriodIndex,以日(日历)作为默认频率

timedelta_range([start, end, periods, freq, …]):返回固定频率TimedeltaIndex,以day作为默认频率

infer_freq(index[, warn]):根据输入索引推断最可能的频率。

顶级处理间隔

interval_range([start, end, periods, freq, …]):返回固定频率IntervalIndex

顶级评估

eval(expr[, parser, engine, truediv, …]):使用各种后端将Python表达式评估为字符串

Series

构造函数

Series([data, index, dtype, name, copy, …]):带轴标签的一维ndarray(包括时间序列).

属性

Axes

Series.index:系列的索引(轴标签)

Series.values:返回系列为ndarray或ndarray-like取决于dtype

Series.dtype:返回基础数据的dtype对象

Series.ftype:如果数据稀疏则返回

Series.shape:返回基础数据形状的元组

Series.nbytes:返回基础数据中的字节数

Series.ndim:根据定义1,返回基础数据的维数

Series.size:返回基础数据中的元素数量

Series.strides:返回基础数据的步幅

Series.itemsize:返回基础数据项的dtype的大小

Series.base:如果共享基础数据的内存,则返回基础对象

Series.T:返回转置,根据定义自我

Series.memory_usage([index, deep]):返回Series的内存使用情况。

Series.hasnans:如果我有任何nans,我会回来; 实现各种性能加速

Series.flags

Series.empty

Series.dtypes:返回基础数据的dtype对象

Series.ftypes:如果数据稀疏则返回

Series.data:返回基础数据的数据指针

Series.is_copy

Series.name

Series.put(*args, **kwargs):将put方法应用于其values属性(如果有)

转换

Series.astype(dtype[, copy, errors]):将pandas对象转换为指定的dtypedtype。

Series.infer_objects():尝试推断对象列的更好的dtypes。

Series.convert_objects([convert_dates, …]):(DEPRECATED)尝试推断对象列的更好dtype。

Series.copy([deep]):复制此对象的索引和数据。

Series.bool():返回单个元素PandasObject的bool。

Series.to_period([freq, copy]):将Series从DatetimeIndex转换为具有所需频率的PeriodIndex(如果未传递,则从索引推断)

Series.to_timestamp([freq, how, copy]):在期间开始时转换为时间戳的datetimedex

Series.tolist():返回值列表。

Series.get_values():与值相同(但处理稀疏转换); 是一种观点

索引, 迭代

Series.get(key[, default]):从给定键的对象获取项目(DataFrame列,Panel切片等)。

Series.at访问行/列标签对的单个值。

Series.iat按整数位置访问行/列对的单个值。

Series.loc通过标签或布尔数组访问一组行和列。

Series.iloc纯粹基于整数位置的索引,用于按位置选择。

Series.__iter__():返回值的迭代器。

Series.iteritems():懒惰地迭代(索引,值)元组

Series.items():懒惰地迭代(索引,值)元组

Series.keys():索引的别名

Series.pop(item):返回项目并从框架中删除。

Series.item():将基础数据的第一个元素作为python标量返回

Series.xs(key[, axis, level, drop_level]):返回Series / DataFrame的横截面(行或列)。

For more information on .at.iat.loc, and .iloc, see the indexing documentation

二元运算符函数

Series.add(other[, level, fill_value, axis]):添加系列和其他元素(二元运算符添加)。

Series.sub(other[, level, fill_value, axis]):减去序列和其他元素(二元运算符)。

Series.mul(other[, level, fill_value, axis]):系列和其他的乘法,元素(二元运算符mul)。

Series.div(other[, level, fill_value, axis]):系列和其他的浮动划分,元素方式(二元算子truediv)。

Series.truediv(other[, level, fill_value, axis]):系列和其他的浮动划分,元素方式(二元算子truediv)。

Series.floordiv(other[, level, fill_value, axis]):系列和其他的整数除法,元素方式(二元运算符floordiv)。

Series.mod(other[, level, fill_value, axis]):系列和其他的模数,元素方式(二元运算符mod)。

Series.pow(other[, level, fill_value, axis]):系列和其他元素的指数幂(二元运算符pow)。

Series.radd(other[, level, fill_value, axis]):添加系列和其他元素(二元运算符radd)。

Series.rsub(other[, level, fill_value, axis]):减去序列和其他元素(二元运算符rsub)。

Series.rmul(other[, level, fill_value, axis]):系列和其他的乘法,元素(二元运算符rmul)。

Series.rdiv(other[, level, fill_value, axis]):系列和其他的浮动划分,元素方式(二元算子rtruediv)。

Series.rtruediv(other[, level, fill_value, axis]):系列和其他的浮动划分,元素方式(二元算子rtruediv)。

Series.rfloordiv(other[, level, fill_value, …]):系列和其他的整数除法,元素方式(二元运算符rfloordiv)。

Series.rmod(other[, level, fill_value, axis]):系列和其他的模数,元素方式(二元运算符rmod)。

Series.rpow(other[, level, fill_value, axis]):系列和其他元素的指数幂(二元运算符rpow)。

Series.combine(other, func[, fill_value]):当一个系列或另一个系列中缺少索引时,使用给定函数对两个系列执行元素二进制运算,并带有可选填充值

Series.combine_first(other):组合系列值,首先选择调用Series的值。

Series.round([decimals]):将系列中的每个值舍入到给定的小数位数。

Series.lt(other[, level, fill_value, axis]):少于系列和其他元素(二元运算符lt)。

Series.gt(other[, level, fill_value, axis]):大于系列和其他元素(二元运算符gt)。

Series.le(other[, level, fill_value, axis]):小于或等于系列等,逐元素(二元运算)。

Series.ge(other[, level, fill_value, axis]):大于或等于系列和其他元素(二元运算符ge)。

Series.ne(other[, level, fill_value, axis]):不等于系列和其他元素(二元运算符ne)。

Series.eq(other[, level, fill_value, axis]):等于系列和其他元素(二元运算符eq)。

Series.product([axis, skipna, level, …]):返回请求轴的值的乘积

Series.dot(other):矩阵乘法与DataFrame或内部产品与Series对象。

Function application, GroupBy & Window

Series.apply(func[, convert_dtype, args]):调用Series的值的函数。

Series.agg(func[, axis]):使用指定轴上的一个或多个操作进行聚合。

Series.aggregate(func[, axis]):使用指定轴上的一个或多个操作进行聚合。

Series.transform(func, *args, **kwargs):调用函数生成类似索引的NDFrame并返回带有转换值的NDFrame

Series.map(arg[, na_action]):使用输入对应(字典,系列或函数)映射Series的值。

Series.groupby([by, axis, level, as_index, …]):使用mapper(dict或key函数,将给定函数应用于组,将结果作为系列返回)或通过一系列列的组系列。

Series.rolling(window[, min_periods, …]):提供滚动窗口计算。

Series.expanding([min_periods, center, axis]):提供扩展转换。

Series.ewm([com, span, halflife, alpha, …]):提供指数加权函数

Series.pipe(func, *args, **kwargs):应用func(self,* args,** kwargs)

计算/ 描述性统计

Series.abs():返回具有每个元素的绝对数值的Series / DataFrame

Series.all([axis, bool_only, skipna, level]):返回是否所有元素都是True,可能是在轴上。

Series.any([axis, bool_only, skipna, level]):返回任何元素在请求的轴上是否为True

Series.autocorr([lag]):Lag-N自相关

Series.between(left, right[, inclusive]):返回boolean Series等效于left <= series <= right

Series.clip([lower, upper, axis, inplace]):在输入阈值处修剪值。

Series.clip_lower(threshold[, axis, inplace]):返回值低于阈值截断的输入的副本。

Series.clip_upper(threshold[, axis, inplace]):输入的返回副本,其值超过给定值(截断)。

Series.corr(other[, method, min_periods]):计算与其他系列的相关性,不包括缺失值

Series.count([level]):返回系列中非NA / null观测值的返回数

Series.cov(other[, min_periods]):计算与Series的协方差,不包括缺失值

Series.cummax([axis, skipna]):返回DataFrameSeries轴上的累积最大值。

Series.cummin([axis, skipna]):返回DataFrameSeries轴上的累积最小值。

Series.cumprod([axis, skipna]):通过DataFrameSeries轴返回累积产品。

Series.cumsum([axis, skipna]):返回DataFrameSeries轴上的累积和。

Series.describe([percentiles, include, exclude]):生成描述性统计数据,总结数据集分布的集中趋势,分散和形状,不包括NaN值。

Series.diff([periods]):第一个离散的元素差异。

Series.factorize([sort, na_sentinel]):将对象编码为枚举类型或分类变量。

Series.kurt([axis, skipna, level, numeric_only]):使用Fisher对峰度的定义(正常峰度== 0.0),在请求轴上返回无偏峰度。

Series.mad([axis, skipna, level]):返回请求轴的值的平均绝对偏差

Series.max([axis, skipna, level, numeric_only]):此方法返回对象中的最大值。

Series.mean([axis, skipna, level, numeric_only]):返回请求轴的值的平均值

Series.median([axis, skipna, level, …]):返回请求轴的值的中值

Series.min([axis, skipna, level, numeric_only]):此方法返回对象中的最小值。

Series.mode():返回数据集的模式。

Series.nlargest([n, keep]):返回最大的n元素。

Series.nsmallest([n, keep]):返回最小的n元素。

Series.pct_change([periods, fill_method, …]):当前元素和先前元素之间的百分比变化。

Series.prod([axis, skipna, level, …]):返回请求轴的值的乘积

Series.quantile([q, interpolation]):给定分位数处的返回值,即la numpy.percentile

Series.rank([axis, method, numeric_only, …]):沿轴计算数值数据等级(1n)。

Series.sem([axis, skipna, level, ddof, …]):在请求的轴上返回均值的无偏标准误差。

Series.skew([axis, skipna, level, numeric_only]):返回请求轴的无偏偏差,由N-1归一化

Series.std([axis, skipna, level, ddof, …]):返回请求轴上的样本标准偏差。

Series.sum([axis, skipna, level, …]):返回请求轴的值的总和

Series.var([axis, skipna, level, ddof, …]):在请求的轴上返回无偏差异。

Series.kurtosis([axis, skipna, level, …]):使用Fisher对峰度的定义(正常峰度== 0.0),在请求轴上返回无偏峰度。

Series.unique():返回Series对象的唯一值。

Series.nunique([dropna]):返回对象中唯一元素的数量。

Series.is_unique如果对象中的值是唯一的,则返回布尔值

Series.is_monotonic如果对象中的值是monotonic_increasing,则返回布尔值

Series.is_monotonic_increasing如果对象中的值是monotonic_increasing,则返回布尔值

Series.is_monotonic_decreasing如果对象中的值是monotonic_decreasing,则返回布尔值

Series.value_counts([normalize, sort, …]):返回包含唯一值计数的对象。

Series.compound([axis, skipna, level]):返回请求轴的值的复合百分比

Series.nonzero():返回非零元素的整数索引

Series.ptp([axis, skipna, level, numeric_only]):返回最大值和之间的差值

重新索引/ 选择/ 标签操作

Series.align(other[, join, axis, level, …]):使用指定的每个轴索引的连接方法将轴上的两个对象对齐

Series.drop([labels, axis, index, columns, …]):返回已删除指定索引标签的系列。

Series.drop_duplicates([keep, inplace]):返回系列,删除重复值。

Series.duplicated([keep]):指示重复的系列值。

Series.equals(other):确定两个NDFrame对象是否包含相同的元素。

Series.first(offset):用于基于日期偏移量化时间序列数据的初始时段的便捷方法。

Series.head([n]):返回前n行。

Series.idxmax([axis, skipna]):返回最大值的行标签。

Series.idxmin([axis, skipna]):返回最小值的行标签。

Series.isin(values):检查系列中是否包含

Series.last(offset):用于基于日期偏移量化时间序列数据的最终时段的便捷方法。

Series.reindex([index]):使用可选填充逻辑将系列符合到新索引,将NA / NaN放置在先前索引中没有值的位置。

Series.reindex_like(other[, method, copy, …]):将具有匹配索引的对象返回给我自己。

Series.rename([index]):更改系列索引标签或名称

Series.rename_axis(mapper[, axis, copy, inplace]):更改索引或列的名称。

Series.reset_index([level, drop, name, inplace]):使用索引重置生成新的DataFrameSeries

Series.sample([n, frac, replace, weights, …]):从对象轴返回随机的项目样本。

Series.select(crit[, axis]):DEPRECATED)返回与轴标签匹配条件对应的数据

Series.set_axis(labels[, axis, inplace]):将所需索引分配给给定轴。

Series.take(indices[, axis, convert, is_copy]):沿轴返回给定位置索引中的元素。

Series.tail([n]):返回最后n行。

Series.truncate([before, after, axis, copy]):在某个索引值之前和之后截断SeriesDataFrame

Series.where(cond[, other, inplace, axis, …]):返回与self相同形状的对象,其对应的条目来自self,其中condTrue,否则来自其他

Series.mask(cond[, other, inplace, axis, …]):返回与self相同形状的对象,其对应的条目来自self,其中condFalse,否则来自other

Series.add_prefix(prefix):带有字符串前缀的前缀标签。

Series.add_suffix(suffix):带有字符串后缀的后缀标签。

Series.filter([items, like, regex, axis]):根据指定索引中的标签设置数据框的行或列。

缺少数据处理

Series.isna():检测缺失值。

Series.notna():检测现有(非缺失)值。

Series.dropna([axis, inplace]):返回删除了缺失值的新系列。

Series.fillna([value, method, axis, …]):使用指定的方法填充NA / NaN

Series.interpolate([method, axis, limit, …]):根据不同的方法插值。

重塑, 排序

Series.argsort([axis, kind, order]):覆盖ndarray.argsort

Series.reorder_levels(order):使用输入顺序重新排列索引级别。

Series.sort_values([axis, ascending, …]):按值排序。

Series.sort_index([axis, level, ascending, …]):按索引标签排序系列。

Series.swaplevel([i, j, copy]):MultiIndex中交换ij级别

Series.unstack([level, fill_value]):Unstack,又名

Series.searchsorted(value[, side, sorter]):查找应插入元素以维护顺序的索引。

Series.ravel([order]):将展平的底层数据作为ndarray返回

Series.repeat(repeats, *args, **kwargs):重复系列的元素。

Series.squeeze([axis]):挤压长度1维。

Series.view([dtype]):创建系列的新视图。

合并/ 加入

Series.append(to_append[, ignore_index, …]):连接两个或更多系列

Series.replace([to_replace, value, inplace, …]):替换给定的值to_replace与价值.

Series.update(other):使用传递的Series中的非NA值修改系列

时间序列

Series.asfreq(freq[, method, how, …]):TimeSeries转换为指定的频率。

Series.asof(where[, subset]):获取没有任何NaN的最后一行(或者在没有NaN的情况下考虑仅使用DataFrame情况下的列子集的最后一行)

Series.shift([periods, freq, axis]):使用可选的时间频率按期望的周期数移动索引

Series.first_valid_index():返回第一个非NA / null值的索引。

Series.last_valid_index():返回最后一个非NA / null值的索引。

Series.resample(rule[, how, axis, …]):频率转换和时间序列重采样的便捷方法。

Series.tz_convert(tz[, axis, level, copy]):tz感知轴转换为目标时区。

Series.tz_localize(tz[, axis, level, copy, …]):tz-naive TimeSeries本地化为目标时区。

Series.at_time(time[, asof]):在特定时间选择值(例如,

Series.between_time(start_time, end_time[, …]):选择一天中特定时间之间的值(例如,上午900-930)。

Series.tshift([periods, freq, axis]):如果可用,使用索引的频率来移动时间索引。

Series.slice_shift([periods, axis]):相当于移位而不复制数据。

类似日期的属性

Series.dt可用于以datetimelike的形式访问系列的值并返回多个属性。这些可以像访问Series.dt.<property>.

日期时间属性

Series.dt.date:返回numpy数组的python datetime.date对象(即没有时区信息的Timestamps的日期部分)。

Series.dt.time:返回datetime.timenumpy数组。

Series.dt.year:日期时间

Series.dt.month:月份为1= 112= 12

Series.dt.day:日期时间的日子

Series.dt.hour:日期时间

Series.dt.minute:日期时间的分钟

Series.dt.second:日期时间的秒数

Series.dt.microsecond:日期时间的微秒

Series.dt.nanosecond:日期时间的纳秒

Series.dt.week:一年中的一周序数

Series.dt.weekofyear:一年中的一周序数

Series.dt.dayofweek:星期一= 0,星期日= 6的星期几

Series.dt.weekday:星期一= 0,星期日= 6的星期几

Series.dt.dayofyear:一年中的序数日

Series.dt.quarter:日期的四分之一

Series.dt.is_month_start:逻辑指示是否每月的第一天(由频率定义)

Series.dt.is_month_end:指示日期是否是该月的最后一天。

Series.dt.is_quarter_start:指示日期是否是一个季度的第一天。

Series.dt.is_quarter_end:指示日期是否是一个季度的最后一天。

Series.dt.is_year_start:指明日期是否是一年的第一天。

Series.dt.is_year_end:指明日期是一年中的最后一天。

Series.dt.is_leap_year:布尔指示符,如果日期属于闰年。

Series.dt.daysinmonth:本月的天数

Series.dt.days_in_month:本月的天数

日期时间方法

Series.dt.to_period(*args, **kwargs):以特定频率转换为PeriodIndex。

Series.dt.to_pydatetime():将数据作为本机Python日期时间对象的数组返回

Series.dt.tz_localize(*args, **kwargs):将tz-naive DatetimeIndex本地化为tz-aware DatetimeIndex。

Series.dt.tz_convert(*args, **kwargs):将tz-aware DatetimeIndex从一个时区转换为另一个时区。

Series.dt.normalize(*args, **kwargs):将时间转换为午夜。

Series.dt.strftime(*args, **kwargs):使用指定的date_format转换为Index。

Series.dt.round(*args, **kwargs):将数据舍入到指定的频率

Series.dt.floor(*args, **kwargs):将数据置于指定的频率

Series.dt.ceil(*args, **kwargs):将数据ceil到指定的频率

Series.dt.month_name(*args, **kwargs):返回具有指定语言环境的DateTimeIndex的月份名称。

Series.dt.day_name(*args, **kwargs):返回具有指定语言环境的DateTimeIndex的日期名称。

Timedelta 属性

Series.dt.days:每个元素的天数。

Series.dt.seconds:每个元素的秒数(> = 0且小于1天)。

Series.dt.microseconds:每个元素的微秒数(> = 0且小于1秒)。

Series.dt.nanoseconds:每个元素的纳秒数(> = 0且小于1微秒)。

Series.dt.components:返回Timedeltas的组件(天,小时,分钟,秒,毫秒,微秒,纳秒)的数据帧。

Timedelta 方法

Series.dt.to_pytimedelta():返回本机datetime.timedelta对象的数组.

Series.dt.total_seconds(*args, **kwargs):返回每个元素的总持续时间,以秒为单位表示

字符串处理

Series.str可用于以字符串形式访问系列的值,并对其应用多种方法。这些可以像访问Series.str.<function/property>.

Series.str.capitalize():将Series / Index中的字符串转换为大写。

Series.str.cat([others, sep, na_rep, join]):使用给定的分隔符连接Series / Index中的字符串。

Series.str.center(width[, fillchar]):使用附加字符填充系列/索引中字符串的左侧和右侧。

Series.str.contains(pat[, case, flags, na, …]):测试模式或正则表达式是否包含在系列或索引的字符串中。

Series.str.count(pat[, flags]):计算系列/索引的每个字符串中模式的出现次数。

Series.str.decode(encoding[, errors]):使用指定的编码解码系列/索引中的字符串。

Series.str.encode(encoding[, errors]):使用指定的编码对系列/索引中的字符串进行编码。

Series.str.endswith(pat[, na]):测试每个字符串元素的结尾是否与模式匹配。

Series.str.extract(pat[, flags, expand]):对于系列中的每个主题字符串,从正则表达式pat的第一个匹配中提取组。

Series.str.extractall(pat[, flags]):对于系列中的每个主题字符串,从正则表达式pat的所有匹配中提取组。

Series.str.find(sub[, start, end]):返回Series / Index中每个字符串中的最低索引,其中子字符串完全包含在[start:end]之间。

Series.str.findall(pat[, flags]):在系列/索引中查找所有出现的模式或正则表达式。

Series.str.get(i):从指定位置的每个组件中提取元素。

Series.str.index(sub[, start, end]):返回每个字符串中的最低索引,其中子字符串完全包含在[start:end]之间。

Series.str.join(sep):使用传递的分隔符连接包含在Series / Index中的元素的列表。

Series.str.len():计算系列/索引中每个字符串的长度。

Series.str.ljust(width[, fillchar]):使用附加字符填充系列/索引中字符串的右侧。

Series.str.lower():将Series / Index中的字符串转换为小写。

Series.str.lstrip([to_strip]):从左侧的系列/索引中的每个字符串中删除空格(包括换行符)。

Series.str.match(pat[, case, flags, na, …]):确定每个字符串是否与正则表达式匹配。

Series.str.normalize(form):返回Series / Index中字符串的Unicode普通表单。

Series.str.pad(width[, side, fillchar]):在系列/索引中填充字符串,并在指定的一侧添加一个字符。

Series.str.partition([pat, expand]):在第一次出现sep拆分字符串,并返回包含分隔符之前的部分的3个元素,分隔符本身以及分隔符之后的部分。

Series.str.repeat(repeats):按指定的次数复制系列/索引中的每个字符串。

Series.str.replace(pat, repl[, n, case, …]):用一些其他字符串替换Series / Index中出现的pattern / regex。

Series.str.rfind(sub[, start, end]):返回Series / Index中每个字符串中的最高索引,其中子字符串完全包含在[start:end]之间。

Series.str.rindex(sub[, start, end]):返回每个字符串中的最高索引,其中子字符串完全包含在[start:end]之间。

Series.str.rjust(width[, fillchar]):使用附加字符填充系列/索引中字符串的左侧。

Series.str.rpartition([pat, expand]):在最后一次出现sep拆分字符串,并返回包含分隔符之前的部分的3个元素,分隔符本身以及分隔符之后的部分。

Series.str.rstrip([to_strip]):从右侧的系列/索引中的每个字符串中删除空格(包括换行符)。

Series.str.slice([start, stop, step]):从系列/索引中的每个元素切片子串

Series.str.slice_replace([start, stop, repl]):用另一个值替换字符串的位置切片。

Series.str.split([pat, n, expand]):在给定的分隔符/分隔符周围拆分字符串。

Series.str.rsplit([pat, n, expand]):通过给定的分隔符字符串拆分Series / Index中的每个字符串,从字符串的末尾开始并向前工作。

Series.str.startswith(pat[, na]):测试每个字符串元素的开头是否与模式匹配。

Series.str.strip([to_strip]):从左侧和右侧剥离系列/索引中每个字符串的空白(包括换行符)。

Series.str.swapcase():将Series / Index中的字符串转换为swapcased。

Series.str.title():将系列/索引中的字符串转换为标题。

Series.str.translate(table[, deletechars]):通过给定的映射表映射字符串中的所有字符。

Series.str.upper():将Series / Index中的字符串转换为大写。

Series.str.wrap(width, **kwargs):将Series / Index中的长字符串换行,以长度小于给定宽度的段落格式化。

Series.str.zfill(width):使用0填充Series / Index中字符串的左侧。

Series.str.isalnum():检查Series / Index中每个字符串中的所有字符是否为字母数字。

Series.str.isalpha():检查Series / Index中每个字符串中的所有字符是否都是字母。

Series.str.isdigit():检查Series / Index中每个字符串中的所有字符是否为数字。

Series.str.isspace():检查Series / Index中每个字符串中的所有字符是否都是空格。

Series.str.islower():检查Series / Index中每个字符串中的所有字符是否都是小写。

Series.str.isupper():检查Series / Index中每个字符串中的所有字符是否都是大写。

Series.str.istitle():检查Series / Index中每个字符串中的所有字符是否都是标题。

Series.str.isnumeric():检查Series / Index中每个字符串中的所有字符是否都是数字。

Series.str.isdecimal():检查Series / Index中每个字符串中的所有字符是否为十进制。

Series.str.get_dummies([sep]):用sep拆分Series中的每个字符串,并返回一个虚拟/指示变量框。

分类

Pandas定义了一种自定义数据类型,用于表示只能使用有限的固定值集的数据。a的dtype Categorical可以用a来描述pandas.api.types.CategoricalDtype.

api.types.CategoricalDtype.categories:一个Index包含被允许的唯一类别。

api.types.CategoricalDtype.ordered:类别是否具有有序关系

api.types.CategoricalDtype([categories, ordered]):键入具有类别和有序性的分类数据

分类数据可以存储在 pandas.Categorical

Categorical(values[, categories, ordered, …]):表示经典R / S-plus方式的分类变量

Categorical.from_codes()已有类别和整数代码时,可以使用替代构造函数:

Categorical.from_codes(codes, categories[, …]):从代码和类别数组中创建分类类型.

dtype信息可在 Categorical

Categorical.dtype:在CategoricalDtype此实例

Categorical.categories:这种分类的类别。

Categorical.ordered:类别是否具有有序关系

Categorical.codes:此类别的类别代码。

np.asarray(categorical)通过实现数组接口工作。请注意,这会将Categorical转换回NumPy数组,因此不会保留类别和订单信息! 

Categorical.__array__([dtype]):numpy数组接口

Categorical可以存储在Series或中DataFrame。要创建一个D型系列category,使用或 其中的两种cat = s.astype(dtype)Series(..., dtype=dtype)dtype

如果Series是dtype CategoricalDtypeSeries.cat则可用于更改分类数据。此访问器类似于Series.dtSeries.str具有以下可用方法和属性:

Series.cat.categories:这种分类的类别。

Series.cat.ordered:类别是否具有有序关系

Series.cat.rename_categories(*args, **kwargs):重命名类别。

Series.cat.reorder_categories(*args, **kwargs):重新排序new_categories中指定的类别。

Series.cat.add_categories(*args, **kwargs):添加新类别。

Series.cat.remove_categories(*args, **kwargs):删除指定的类别。

Series.cat.remove_unused_categories(*args, …):删除未使用的类别。

Series.cat.set_categories(*args, **kwargs):将类别设置为指定的new_categories。

Series.cat.as_ordered(*args, **kwargs):设置要排序的分类

Series.cat.as_unordered(*args, **kwargs):将Categorical设置为无序

绘图

Series.plot对于表单的特定绘图方法,它既是可调用方法又是命名空间属性Series.plot.<kind>.

Series.plot([kind, ax, figsize, ….]):系列绘图访问器和方法

Series.hist([by, ax, grid, xlabelsize, …]):使用matplotlib绘制输入序列的直方图

Series.plot.area(**kwds):区域情节

Series.plot.bar(**kwds):垂直条形图

Series.plot.barh(**kwds):单杠图

Series.plot.box(**kwds):箱形图

Series.plot.density([bw_method, ind]):使用高斯核生成核密度估计图。

Series.plot.hist([bins]):直方图

Series.plot.kde([bw_method, ind]):使用高斯核生成核密度估计图。

Series.plot.line(**kwds):线图

Series.plot.pie(**kwds):饼形图

序列化/ IO / 转换

Series.to_pickle(path[, compression, protocol]):Pickle(序列化)对象到文件。

Series.to_csv([path, index, sep, na_rep, …]):将Series写入逗号分隔值(csv)文件

Series.to_dict([into]):将Series转换为{label - > value} dict或dict-like对象。

Series.to_excel(excel_writer[, sheet_name, …]):将系列写入Excel工作表

Series.to_frame([name]):将Series转换为DataFrame

Series.to_xarray():从pandas对象返回一个xarray对象。

Series.to_hdf(path_or_buf, key, **kwargs):使用HDFStore将包含的数据写入HDF5文件。

Series.to_sql(name, con[, schema, …]):将存储在DataFrame中的记录写入SQL数据库。

Series.to_msgpack([path_or_buf, encoding]):msgpack(序列化)对象输入文件路径

Series.to_json([path_or_buf, orient, …]):将对象转换为JSON字符串。

Series.to_sparse([kind, fill_value]):将Series转换为SparseSeries

Series.to_dense():返回NDFrame的密集表示(与稀疏相反)

Series.to_string([buf, na_rep, …]):渲染系列的字符串表示形式

Series.to_clipboard([excel, sep]):将对象复制到系统剪贴板。

Series.to_latex([buf, columns, col_space, …]):将对象渲染到表格环境表。

Sparse

SparseSeries.to_coo([row_levels, …]):使用MultiIndex从SparseSeries创建scipy.sparse.coo_matrix.

SparseSeries.from_coo(A[, dense_index]):从scipy.sparse.coo_matrix创建SparseSeries.

DataFrame

构造函数

DataFrame([data, index, columns, dtype, copy]):具有标记轴(行和列)的二维大小可变,可能异构的表格数据结构.

属性和基础数据

Axes

DataFrame.dtypes:返回DataFrame中的dtypes。

DataFrame.ftypes:返回DataFrame中的ftypes(稀疏/密集和dtype的指示)。

DataFrame.get_dtype_counts():返回此对象中唯一dtypes的计数。

DataFrame.get_ftype_counts():(DEPRECATED)返回此对象中唯一ftypes的计数。

DataFrame.select_dtypes([include, exclude]):根据列dtypes返回DataFrame列的子集。

DataFrame.values:返回DataFrame的Numpy表示。

DataFrame.get_values():将稀疏值转换为密集后返回一个ndarray。

DataFrame.axes:返回表示DataFrame轴的列表。

DataFrame.ndim:返回表示轴/数组维数的int。

DataFrame.size:返回一个int,表示此对象中的元素数。

DataFrame.shape:返回表示DataFrame维度的元组。

DataFrame.memory_usage([index, deep]):以字节为单位返回每列的内存使用情况。

DataFrame.empty:指示DataFrame是否为空。

DataFrame.index:DataFrame的索引(行标签)。

DataFrame.columns:DataFrame的列标签。

转换

DataFrame.astype(dtype[, copy, errors]):将pandas对象转换为指定的dtypedtype。

DataFrame.convert_objects([convert_dates, …]):(DEPRECATED)尝试推断对象列的更好dtype。

DataFrame.infer_objects():尝试推断对象列的更好的dtypes。

DataFrame.copy([deep]):复制此对象的索引和数据。

DataFrame.isna():检测缺失值。

DataFrame.notna():检测现有(非缺失)值。

DataFrame.bool():返回单个元素PandasObject的bool。

索引, 迭代

DataFrame.head([n]):返回前n行。

DataFrame.at:访问行/列标签对的单个值。

DataFrame.iat:按整数位置访问行/列对的单个值。

DataFrame.loc:通过标签或布尔数组访问一组行和列。

DataFrame.iloc:纯粹基于整数位置的索引,用于按位置选择。

DataFrame.insert(loc, column, value[, …]):将列插入指定位置的DataFrame。

DataFrame.insert(loc, column, value[, …]):将列插入指定位置的DataFrame。

DataFrame.__iter__():迭代infor轴

DataFrame.items():迭代器(列名,系列)对。

DataFrame.keys():获取“信息轴”(请参阅​​索引了解更多信息)

DataFrame.iteritems():迭代器(列名,系列)对。

DataFrame.iterrows():将DataFrame行迭代为(index,Series)对。

DataFrame.itertuples([index, name]):将DataFrame行作为namedtuples迭代,索引值作为元组的第一个元素。

DataFrame.lookup(row_labels, col_labels):DataFrame的基于标签的“花式索引”功能。

DataFrame.pop(item):返回项目并从框架中删除。

DataFrame.tail([n]):返回最后n行。

DataFrame.xs(key[, axis, level, drop_level]):返回Series / DataFrame的横截面(行或列)。

DataFrame.get(key[, default]):从给定键的对象获取项目(DataFrame列,Panel切片等)。

DataFrame.isin(values):返回boolean DataFrame,显示DataFrame中的每个元素是否包含在值中。

DataFrame.where(cond[, other, inplace, …]):返回与self相同形状的对象,其对应的条目来自self,其中cond为True,否则来自其他

DataFrame.mask(cond[, other, inplace, axis, …]):返回与self相同形状的对象,其对应的条目来自self,其中cond为False,否则来自other

DataFrame.query(expr[, inplace]):使用布尔表达式查询帧的列。

For more information on .at.iat.loc, and .iloc, see the indexing documentation

二元运算符函数

DataFrame.add(other[, axis, level, fill_value]):添加数据帧和其他元素(二元运算符添加)。

DataFrame.sub(other[, axis, level, fill_value]):减去数据帧和其他元素(二元运算符)。

DataFrame.mul(other[, axis, level, fill_value]):数据帧和其他元素的乘法(二元运算符mul)。

DataFrame.div(other[, axis, level, fill_value]):浮动划分数据帧和其他元素(二元运算符truediv)。

DataFrame.truediv(other[, axis, level, …]):浮动划分数据帧和其他元素(二元运算符truediv)。

DataFrame.floordiv(other[, axis, level, …]):数据帧和其他元素的整数划分(二元运算符floordiv)。

DataFrame.mod(other[, axis, level, fill_value]):数据帧的模数和其他元素(二元运算符mod)。

DataFrame.pow(other[, axis, level, fill_value]):数据帧和其他元素的指数幂(二元运算符pow)。

DataFrame.dot(other):矩阵乘法与DataFrame或Series对象。

DataFrame.radd(other[, axis, level, fill_value]):添加数据帧和其他元素(二元运算符radd)。

DataFrame.rsub(other[, axis, level, fill_value]):减去数据帧和其他元素(二元运算符rsub)。

DataFrame.rmul(other[, axis, level, fill_value]):数据帧和其他元素的乘法(二元运算符rmul)。

DataFrame.rdiv(other[, axis, level, fill_value]):数据帧和其他元素的浮动划分(二元运算符rtruediv)。

DataFrame.rtruediv(other[, axis, level, …]):数据帧和其他元素的浮动划分(二元运算符rtruediv)。

DataFrame.rfloordiv(other[, axis, level, …]):数据帧和其他元素的整数划分(二元运算符rfloordiv)。

DataFrame.rmod(other[, axis, level, fill_value]):数据帧的模数和其他元素(二元运算符rmod)。

DataFrame.rpow(other[, axis, level, fill_value]):数据帧和其他元素的指数幂(二元运算符rpow)。

DataFrame.lt(other[, axis, level]):用于灵活比较方法的包装器

DataFrame.gt(other[, axis, level]):用于灵活比较方法的包装器gt

DataFrame.le(other[, axis, level]):用于灵活比较方法的包装器

DataFrame.ge(other[, axis, level]):包装用于灵活的比较方法ge

DataFrame.ne(other[, axis, level]):用于灵活比较方法的包装器

DataFrame.eq(other[, axis, level]):用于灵活比较方法的包装器eq

DataFrame.combine(other, func[, fill_value, …]):添加两个DataFrame对象并且不传播NaN值,因此如果对于(列,时间)一个帧缺少值,它将默认为另一个帧的值(也可能是NaN)

DataFrame.combine_first(other):将两个DataFrame对象组合在一起,默认为调用该方法的帧中的非空值。

Function application, GroupBy & Window

DataFrame.apply(func[, axis, broadcast, …]):沿DataFrame的轴应用函数。

DataFrame.applymap(func):将函数元素应用于Dataframe。

DataFrame.pipe(func, *args, **kwargs):应用func(self,* args,** kwargs)

DataFrame.agg(func[, axis]):使用指定轴上的一个或多个操作进行聚合。

DataFrame.aggregate(func[, axis]):使用指定轴上的一个或多个操作进行聚合。

DataFrame.transform(func, *args, **kwargs):调用函数生成类似索引的NDFrame并返回带有转换值的NDFrame

DataFrame.groupby([by, axis, level, …]):使用mapper(dict或key函数,将给定函数应用于组,将结果作为系列返回)或通过一系列列的组系列。

DataFrame.rolling(window[, min_periods, …]):提供滚动窗口计算。

DataFrame.expanding([min_periods, center, axis]):提供扩展转换。

DataFrame.ewm([com, span, halflife, alpha, …]):提供指数加权函数

计算/ 描述性统计

DataFrame.abs():返回具有每个元素的绝对数值的Series / DataFrame。

DataFrame.all([axis, bool_only, skipna, level]):返回是否所有元素都是True,可能是在轴上。

DataFrame.any([axis, bool_only, skipna, level]):返回任何元素在请求的轴上是否为True。

DataFrame.clip([lower, upper, axis, inplace]):在输入阈值处修剪值。

DataFrame.clip_lower(threshold[, axis, inplace]):返回值低于阈值截断的输入的副本。

DataFrame.clip_upper(threshold[, axis, inplace]):输入的返回副本,其值超过给定值(截断)。

DataFrame.compound([axis, skipna, level]):返回请求轴的值的复合百分比

DataFrame.corr([method, min_periods]):计算列的成对相关性,不包括NA / null值

DataFrame.corrwith(other[, axis, drop]):计算两个DataFrame对象的行或列之间的成对关联。

DataFrame.count([axis, level, numeric_only]):计算每列或每行的非NA单元格。

DataFrame.cov([min_periods]):计算列的成对协方差,不包括NA / null值。

DataFrame.cummax([axis, skipna]):返回DataFrame或Series轴上的累积最大值。

DataFrame.cummin([axis, skipna]):返回DataFrame或Series轴上的累积最小值。

DataFrame.cumprod([axis, skipna]):通过DataFrame或Series轴返回累积产品。

DataFrame.cumsum([axis, skipna]):返回DataFrame或Series轴上的累积和。

DataFrame.describe([percentiles, include, …]):生成描述性统计数据,总结数据集分布的集中趋势,分散和形状,不包括NaN值。

DataFrame.diff([periods, axis]):第一个离散的元素差异。

DataFrame.eval(expr[, inplace]):评估描述DataFrame列上的操作的字符串。

DataFrame.kurt([axis, skipna, level, …]):使用Fisher对峰度的定义(正常峰度== 0.0),在请求轴上返回无偏峰度。

DataFrame.kurtosis([axis, skipna, level, …]):使用Fisher对峰度的定义(正常峰度== 0.0),在请求轴上返回无偏峰度。

DataFrame.mad([axis, skipna, level]):返回请求轴的值的平均绝对偏差

DataFrame.max([axis, skipna, level, …]):此方法返回对象中的最大值。

DataFrame.mean([axis, skipna, level, …]):返回请求轴的值的平均值

DataFrame.median([axis, skipna, level, …]):返回请求轴的值的中值

DataFrame.min([axis, skipna, level, …]):此方法返回对象中的最小值。

DataFrame.mode([axis, numeric_only]):获取沿所选轴的每个元素的模式。

DataFrame.pct_change([periods, fill_method, …]):当前元素和先前元素之间的百分比变化。

DataFrame.prod([axis, skipna, level, …]):返回请求轴的值的乘积

DataFrame.product([axis, skipna, level, …]):返回请求轴的值的乘积

DataFrame.quantile([q, axis, numeric_only, …]):在请求的轴上返回给定分位数的值,即la numpy.percentile。

DataFrame.rank([axis, method, numeric_only, …]):沿轴计算数值数据等级(1到n)。

DataFrame.round([decimals]):将DataFrame舍入到可变数量的小数位。

DataFrame.sem([axis, skipna, level, ddof, …]):在请求的轴上返回均值的无偏标准误差。

DataFrame.skew([axis, skipna, level, …]):返回请求轴的无偏偏差,由N-1归一化

DataFrame.sum([axis, skipna, level, …]):返回请求轴的值的总和

DataFrame.std([axis, skipna, level, ddof, …]):返回请求轴上的样本标准偏差。

DataFrame.var([axis, skipna, level, ddof, …]):在请求的轴上返回无偏差异。

DataFrame.nunique([axis, dropna]):返回具有所请求轴上的不同观察数的系列。

重新索引/ 选择/ 标签操作

DataFrame.add_prefix(prefix):带有字符串前缀的前缀标签。

DataFrame.add_suffix(suffix):带有字符串后缀的后缀标签。

DataFrame.align(other[, join, axis, level, …]):使用指定的每个轴索引的连接方法将轴上的两个对象对齐

DataFrame.at_time(time[, asof]):在特定时间选择值(例如,

DataFrame.between_time(start_time, end_time):选择一天中特定时间之间的值(例如,上午9:00-9:30)。

DataFrame.drop([labels, axis, index, …]):从行或列中删除指定的标签。

DataFrame.drop_duplicates([subset, keep, …]):返回删除了重复行的DataFrame,可选择仅考虑某些列

DataFrame.duplicated([subset, keep]):返回boolean Series表示重复行,可选择仅考虑某些列

DataFrame.equals(other):确定两个NDFrame对象是否包含相同的元素。

DataFrame.filter([items, like, regex, axis]):根据指定索引中的标签设置数据框的行或列。

DataFrame.first(offset):用于基于日期偏移量化时间序列数据的初始时段的便捷方法。

DataFrame.head([n]):返回前n行。

DataFrame.idxmax([axis, skipna]):返回请求轴上第一次出现最大值的索引。

DataFrame.idxmin([axis, skipna]):返回首次出现最小请求轴的索引。

DataFrame.last(offset):用于基于日期偏移量化时间序列数据的最终时段的便捷方法。

DataFrame.reindex([labels, index, columns, …]):使用可选填充逻辑将DataFrame符合到新索引,将NA / NaN放置在先前索引中没有值的位置。

DataFrame.reindex_axis(labels[, axis, …]):使用可选填充逻辑将输入对象符合到新索引,将NA / NaN放置在先前索引中没有值的位置。

DataFrame.reindex_like(other[, method, …]):将具有匹配索引的对象返回给我自己。

DataFrame.rename([mapper, index, columns, …]):更改轴标签。

DataFrame.rename_axis(mapper[, axis, copy, …]):更改索引或列的名称。

DataFrame.reset_index([level, drop, …]):对于具有多级索引的DataFrame,在索引名称下的列中返回带有标签信息的新DataFrame,默认为“level_0”,“level_1”等。

DataFrame.sample([n, frac, replace, …]):从对象轴返回随机的项目样本。

DataFrame.select(crit[, axis]):(DEPRECATED)返回与轴标签匹配条件对应的数据

DataFrame.set_axis(labels[, axis, inplace]):将所需索引分配给给定轴。

DataFrame.set_index(keys[, drop, append, …]):使用一个或多个现有列设置DataFrame索引(行标签)。

DataFrame.tail([n]):返回最后n行。

DataFrame.take(indices[, axis, convert, is_copy]):沿轴返回给定位置索引中的元素。

DataFrame.truncate([before, after, axis, copy]):在某个索引值之前和之后截断Series或DataFrame。

缺少数据处理

DataFrame.dropna([axis, how, thresh, …]):删除缺失的值。

DataFrame.fillna([value, method, axis, …]):使用指定的方法填充NA / NaN值

DataFrame.replace([to_replace, value, …]):替换给定的值to_replace价值

DataFrame.interpolate([method, axis, limit, …]):根据不同的方法插值。

重塑, 排序, 转置

DataFrame.pivot([index, columns, values]):返回由给定索引/列值组织的重新整形的DataFrame。

DataFrame.pivot_table([values, index, …]):创建一个电子表格样式的数据透视表作为DataFrame。

DataFrame.reorder_levels(order[, axis]):使用输入顺序重新排列索引级别。

DataFrame.sort_values(by[, axis, ascending, …]):按任一轴的值排序

DataFrame.sort_index([axis, level, …]):按标签排序对象(沿轴)

DataFrame.nlargest(n, columns[, keep]):返回第一个ñ通过有序的行按降序排列。

DataFrame.nsmallest(n, columns[, keep]):获取按n最小值排序的DataFrame行。

DataFrame.swaplevel([i, j, axis]):在特定轴上的MultiIndex中交换i和j级别

DataFrame.stack([level, dropna]):将指定级别从列堆叠到索引。

DataFrame.unstack([level, fill_value]):透视(必要的分层)索引标签的级别,返回具有新级别列标签的DataFrame,其最内层级别由透视索引标签组成。

DataFrame.swapaxes(axis1, axis2[, copy]):交换轴和交换值轴适当

DataFrame.melt([id_vars, value_vars, …]):“Unpivots”DataFrame从宽格式到长格式,可选择设置标识符变量。

DataFrame.squeeze([axis]):挤压长度1维。

DataFrame.to_panel():(DEPRECATED)将长(堆叠)格式(DataFrame)转换为宽(3D,Panel)格式。

DataFrame.to_xarray():从pandas对象返回一个xarray对象。

DataFrame.T:转置索引和列。

DataFrame.transpose(*args, **kwargs):转置索引和列。

合并/ 加入

DataFrame.append(other[, ignore_index, …]):将其他行附加到此帧的末尾,返回一个新对象。

DataFrame.assign(**kwargs):将新列分配给DataFrame,返回一个新对象(副本),并将新列添加到原始列中。

DataFrame.join(other[, on, how, lsuffix, …]):在索引或键列上与其他DataFrame连接列。

DataFrame.merge(right[, how, on, left_on, …]):通过按列或索引执行数据库样式的连接操作来合并DataFrame对象。

DataFrame.update(other[, join, overwrite, …]):使用另一个DataFrame中的非NA值进行就地修改。

时间序列

DataFrame.asfreq(freq[, method, how, …]):将TimeSeries转换为指定的频率。

DataFrame.asof(where[, subset]):获取没有任何NaN的最后一行(或者在没有NaN的情况下考虑仅使用DataFrame情况下的列子集的最后一行)

DataFrame.shift([periods, freq, axis]):使用可选的时间频率按期望的周期数移动索引

DataFrame.slice_shift([periods, axis]):相当于移位而不复制数据。

DataFrame.tshift([periods, freq, axis]):如果可用,使用索引的频率来移动时间索引。

DataFrame.first_valid_index():返回第一个非NA / null值的索引。

DataFrame.last_valid_index():返回最后一个非NA / null值的索引。

DataFrame.resample(rule[, how, axis, …]):频率转换和时间序列重采样的便捷方法。

DataFrame.to_period([freq, axis, copy]):使用所需频率将DataFrame从DatetimeIndex转换为PeriodIndex(如果未传递,则从索引推断)

DataFrame.to_timestamp([freq, how, axis, copy]):在期间开始时转换为时间戳的DatetimeIndex

DataFrame.tz_convert(tz[, axis, level, copy]):将tz感知轴转换为目标时区。

DataFrame.tz_localize(tz[, axis, level, …]):将tz-naive TimeSeries本地化为目标时区。

绘图

DataFrame.plot对于表单的特定绘图方法,它既是可调用方法又是命名空间属性DataFrame.plot.<kind>.

DataFrame.plot([x, y, kind, ax, ….]):DataFrame绘制访问器和方法

DataFrame.boxplot([column, by, ax, …]):从DataFrame列创建一个箱形图.

DataFrame.hist([column, by, grid, …]):制作DataFrame的直方图.

DataFrame.plot.area([x, y]):区域情节

DataFrame.plot.bar([x, y]):垂直条形图。

DataFrame.plot.barh([x, y]):制作一个水平条形图。

DataFrame.plot.box([by]):制作DataFrame列的方框图。

DataFrame.plot.density([bw_method, ind]):使用高斯核生成核密度估计图。

DataFrame.plot.hexbin(x, y[, C, …]):生成六边形分箱图。

DataFrame.plot.hist([by, bins]):绘制DataFrame列的一个直方图。

DataFrame.plot.kde([bw_method, ind]):使用高斯核生成核密度估计图。

DataFrame.plot.line([x, y]):将DataFrame列绘制为线条。

DataFrame.plot.pie([y]):生成饼图。

DataFrame.plot.scatter(x, y[, s, c]):创建具有不同标记点大小和颜色的散点图。

序列化/ IO / 转换

DataFrame.from_dict(data[, orient, dtype, …]):从类似数组或dicts的dict构造DataFrame。

DataFrame.from_items(items[, columns, orient]):(DEPRECATED)从元组列表构造数据框

DataFrame.from_records(data[, index, …]):将结构化或记录ndarray转换为DataFrame

DataFrame.info([verbose, buf, max_cols, …]):打印DataFrame的简明摘要。

DataFrame.to_parquet(fname[, engine, …]):将DataFrame写入二进制镶木地板格式。

DataFrame.to_pickle(path[, compression, …]):Pickle(序列化)对象到文件。

DataFrame.to_csv([path_or_buf, sep, na_rep, …]):将DataFrame写入逗号分隔值(csv)文件

DataFrame.to_hdf(path_or_buf, key, **kwargs):使用HDFStore将包含的数据写入HDF5文件。

DataFrame.to_sql(name, con[, schema, …]):将存储在DataFrame中的记录写入SQL数据库。

DataFrame.to_dict([orient, into]):将DataFrame转换为字典。

DataFrame.to_excel(excel_writer[, …]):将DataFrame写入Excel工作表

DataFrame.to_json([path_or_buf, orient, …]):将对象转换为JSON字符串。

DataFrame.to_html([buf, columns, col_space, …]):将DataFrame呈现为HTML表格。

DataFrame.to_feather(fname):写出DataFrames的二进制羽毛格式

DataFrame.to_latex([buf, columns, …]):将对象渲染到表格环境表。

DataFrame.to_stata(fname[, convert_dates, …]):导出Stata二进制dta文件。

DataFrame.to_msgpack([path_or_buf, encoding]):msgpack(序列化)对象输入文件路径

DataFrame.to_gbq(destination_table, project_id):将DataFrame写入Google BigQuery表。

DataFrame.to_records([index, convert_datetime64]):将DataFrame转换为NumPy记录数组。

DataFrame.to_sparse([fill_value, kind]):转换为SparseDataFrame

DataFrame.to_dense():返回NDFrame的密集表示(与稀疏相反)

DataFrame.to_string([buf, columns, …]):将DataFrame渲染为控制台友好的表格输出。

DataFrame.to_clipboard([excel, sep]):将对象复制到系统剪贴板。

DataFrame.style:返回Styler对象的属性,该对象包含用于为DataFrame构建样式化HTML表示的方法

Sparse

SparseDataFrame.to_coo():将帧的内容作为稀疏的SciPy COO矩阵返回.

面板

Attributes and underlying data

Axes

  • 项目:轴0; 每个项目对应一个包含在其中的DataFrame
  • major_axis:轴1; 每个DataFrame的索引(行)
  • minor_axis:轴2; 每个DataFrame的列

Panel.values:返回DataFrameNumpy表示。

Panel.axes:返回内部NDFrame的索引标签

Panel.ndim:返回表示轴/数组维数的int

Panel.size:返回一个int,表示此对象中的元素数。

Panel.shape:返回轴尺寸的元组

Panel.dtypes:返回DataFrame中的dtypes

Panel.ftypes:返回DataFrame中的ftypes(稀疏/密集和dtype的指示)。

Panel.get_dtype_counts():返回此对象中唯一dtypes的计数。

Panel.get_ftype_counts():(DEPRECATED)返回此对象中唯一ftypes的计数

转换

Panel.astype(dtype[, copy, errors]):pandas对象转换为指定的dtype dtype

Panel.copy([deep]):复制此对象的索引和数据。

Panel.isna():检测缺失值。

 

Panel.notna():检测现有(非缺失)值。

索引, 迭代, 切片

Panel.at访问行/列标签对的单个值。

Panel.iat按整数位置访问行/列对的单个值。

Panel.loc通过标签或布尔数组访问一组行和列。

Panel.iloc纯粹基于整数位置的索引,用于按位置选择。

Panel.__iter__():迭代infor

Panel.iteritems():在信息轴上迭代(标签,值)

Panel.pop(item):返回项目并从框架中删除。

Panel.xs(key[, axis]):沿选定轴返回面板切片

Panel.major_xs(key):沿主轴返回面板切片

 

Panel.minor_xs(key):沿短轴返回面板切片

For more information on .at.iat.loc, and .iloc, see the indexing documentation.

Binary operator functions

Panel.add(other[, axis]):添加系列和其他元素(二元运算符添加)。

Panel.sub(other[, axis]):减去序列和其他元素(二元运算符)。

Panel.mul(other[, axis]):系列和其他的乘法,元素(二元运算符mul)。

Panel.div(other[, axis]):系列和其他的浮动划分,元素方式(二元算子truediv)。

Panel.truediv(other[, axis]):系列和其他的浮动划分,元素方式(二元算子truediv)。

Panel.floordiv(other[, axis]):系列和其他的整数除法,元素方式(二元运算符floordiv)。

Panel.mod(other[, axis]):系列和其他的模数,元素方式(二元运算符mod)。

Panel.pow(other[, axis]):系列和其他元素的指数幂(二元运算符pow)。

Panel.radd(other[, axis]):添加系列和其他元素(二元运算符radd)。

Panel.rsub(other[, axis]):减去序列和其他元素(二元运算符rsub)。

Panel.rmul(other[, axis]):系列和其他的乘法,元素(二元运算符rmul)。

Panel.rdiv(other[, axis]):系列和其他的浮动划分,元素方式(二元算子rtruediv)。

Panel.rtruediv(other[, axis]):系列和其他的浮动划分,元素方式(二元算子rtruediv)。

Panel.rfloordiv(other[, axis]):系列和其他的整数除法,元素方式(二元运算符rfloordiv)。

Panel.rmod(other[, axis]):系列和其他的模数,元素方式(二元运算符rmod)。

Panel.rpow(other[, axis]):系列和其他元素的指数幂(二元运算符rpow)。

Panel.lt(other[, axis]):用于比较方法的包装器lt

Panel.gt(other[, axis]):用于比较方法的包装器gt

Panel.le(other[, axis]):用于比较方法的包装器

Panel.ge(other[, axis]):包装用于比较方法ge

Panel.ne(other[, axis]):用于比较方法的包装器ne

Panel.eq(other[, axis]):用于比较方法的包装器eq

Function application, GroupBy

Panel.apply(func[, axis]):沿Panel的轴(或轴)应用功能

Panel.groupby(function[, axis]):在给定轴上分组数据,返回GroupBy对象

计算/ 描述属性

Panel.abs():返回具有每个元素的绝对数值的Series / DataFrame

Panel.clip([lower, upper, axis, inplace]):在输入阈值处修剪值。

Panel.clip_lower(threshold[, axis, inplace]):返回值低于阈值截断的输入的副本。

Panel.clip_upper(threshold[, axis, inplace]):输入的返回副本,其值超过给定值(截断)。

Panel.count([axis]):返回请求轴上的观察数。

Panel.cummax([axis, skipna]):返回DataFrameSeries轴上的累积最大值。

Panel.cummin([axis, skipna]):返回DataFrameSeries轴上的累积最小值。

Panel.cumprod([axis, skipna]):通过DataFrameSeries轴返回累积产品。

Panel.cumsum([axis, skipna]):返回DataFrameSeries轴上的累积和。

Panel.max([axis, skipna, level, numeric_only]):此方法返回对象中的最大值。

Panel.mean([axis, skipna, level, numeric_only]):返回请求轴的值的平均值

Panel.median([axis, skipna, level, numeric_only]):返回请求轴的值的中值

Panel.min([axis, skipna, level, numeric_only]):此方法返回对象中的最小值。

Panel.pct_change([periods, fill_method, …]):当前元素和先前元素之间的百分比变化。

Panel.prod([axis, skipna, level, …]):返回请求轴的值的乘积

Panel.sem([axis, skipna, level, ddof, …]):在请求的轴上返回均值的无偏标准误差。

Panel.skew([axis, skipna, level, numeric_only]):返回请求轴的无偏偏差,由N-1归一化

Panel.sum([axis, skipna, level, …]):返回请求轴的值的总和

Panel.std([axis, skipna, level, ddof, …]):返回请求轴上的样本标准偏差。

Panel.var([axis, skipna, level, ddof, …]):在请求的轴上返回无偏差异。

重新索引/ 选择/ 标签操作

Panel.add_prefix(prefix):带有字符串前缀的前缀标签。

Panel.add_suffix(suffix):带有字符串后缀的后缀标签。

Panel.drop([labels, axis, index, columns, …]):

Panel.equals(other):确定两个NDFrame对象是否包含相同的元素。

Panel.filter([items, like, regex, axis]):根据指定索引中的标签设置数据框的行或列。

Panel.first(offset):用于基于日期偏移量化时间序列数据的初始时段的便捷方法。

Panel.last(offset):用于基于日期偏移量化时间序列数据的最终时段的便捷方法。

Panel.reindex(*args, **kwargs):使用可选填充逻辑将Panel转换为新索引,将NA / NaN放置在先前索引中没有值的位置。

Panel.reindex_axis(labels[, axis, method, …]):使用可选填充逻辑将输入对象符合到新索引,将NA / NaN放置在先前索引中没有值的位置。

Panel.reindex_like(other[, method, copy, …]):将具有匹配索引的对象返回给我自己。

Panel.rename([items, major_axis, minor_axis]):更改轴输入功能。

Panel.sample([n, frac, replace, weights, …]):从对象轴返回随机的项目样本。

Panel.select(crit[, axis]):DEPRECATED)返回与轴标签匹配条件对应的数据

Panel.take(indices[, axis, convert, is_copy]):沿轴返回给定位置索引中的元素。

Panel.truncate([before, after, axis, copy]):在某个索引值之前和之后截断SeriesDataFrame

缺少数据处理

Panel.dropna([axis, how, inplace]):从面板中删除2D,保持传递的轴不变

重塑, 排序, 转置

Panel.sort_index([axis, level, ascending, …]):按标签排序对象(沿轴)

Panel.swaplevel([i, j, axis]):在特定轴上的MultiIndex中交换ij级别

Panel.transpose(*args, **kwargs):置换面板的尺寸

Panel.swapaxes(axis1, axis2[, copy]):交换轴和交换值轴适当

Panel.conform(frame[, axis]):使输入DataFrame符合选定的轴对。

合并/ 加入

Panel.join(other[, how, lsuffix, rsuffix]):在主轴和次轴列上与其他面板连接项目

Panel.update(other[, join, overwrite, …]):使用来自传递的Panel的非NA值或可强制化为Panel的对象来修改面板。

时间序列相关

Panel.asfreq(freq[, method, how, normalize, …]):TimeSeries转换为指定的频率。

Panel.shift([periods, freq, axis]):使用可选的时间频率按期望的周期数移动索引。

Panel.resample(rule[, how, axis, …]):频率转换和时间序列重采样的便捷方法。

Panel.tz_convert(tz[, axis, level, copy]):tz感知轴转换为目标时区。

Panel.tz_localize(tz[, axis, level, copy, …]):tz-naive TimeSeries本地化为目标时区。

序列化/ IO / 转换

Panel.from_dict(data[, intersect, orient, dtype]):DataFrame对象的dict构造Panel

Panel.to_pickle(path[, compression, protocol]):Pickle(序列化)对象到文件。

Panel.to_excel(path[, na_rep, engine]):Panel中的每个DataFrame写入单独的Excel工作表

Panel.to_hdf(path_or_buf, key, **kwargs):使用HDFStore将包含的数据写入HDF5文件。

Panel.to_sparse(*args, **kwargs):NOT IMPLEMENTED:不要调用此方法,因为Panel对象不支持稀疏,并且会引发错误。

Panel.to_frame([filter_observations]):将宽格式转换为长(堆叠)格式,作为DataFrame,其列是Panel的项目,其索引是由Panel的主轴和次轴组成的MultiIndex

Panel.to_clipboard([excel, sep]):将对象复制到系统剪贴板。

索引

其中许多方法或其变体可用于包含索引(Series / DataFrame)的对象,并且最有可能在直接调用这些方法之前使用这些方法或变体.

Index:不可变的ndarray实现有序的可切片集.

属性

Index.values:将基础数据作为ndarray返回

Index.is_monotonic:is_monotonic_increasing的别名(不建议使用)

Index.is_monotonic_increasing:如果索引是单调递增(仅等于或增加)值,则返回。

Index.is_monotonic_decreasing:如果索引是单调递减(仅等于或递减)值,则返回。

Index.is_unique:如果索引具有唯一值,则返回

Index.has_duplicates

Index.hasnans:如果我有任何nans,我会回来; 实现各种性能加速

Index.dtype:返回基础数据的dtype对象

Index.dtype_str:返回基础数据的dtype str

Index.inferred_type:返回从值推断出的类型的字符串

Index.is_all_dates

Index.shape:返回基础数据形状的元组

Index.name

Index.names

Index.nbytes:返回基础数据中的字节数

Index.ndim:根据定义1,返回基础数据的维数

Index.size:返回基础数据中的元素数量

Index.empty

Index.strides:返回基础数据的步幅

Index.itemsize:返回基础数据项的dtype的大小

Index.base:如果共享基础数据的内存,则返回基础对象

Index.T:返回转置,根据定义自我

Index.memory_usage([deep]):内存使用值

修改和计算

Index.all(*args, **kwargs):返回是否所有元素都为True

Index.any(*args, **kwargs):返回任何元素是否为True

Index.argmin([axis]):返回最小参数索引器的ndarray

Index.argmax([axis]):返回最大参数索引器的ndarray

Index.copy([name, deep, dtype]):制作此对象的副本。

Index.delete(loc):删除已传递位置(-s)的新索引

Index.drop(labels[, errors]):删除已传递标签列表的新索引

Index.drop_duplicates([keep]):返回索引,删除重复值。

Index.duplicated([keep]):指示重复的索引值。

Index.equals(other):确定两个Index对象是否包含相同的元素。

Index.factorize([sort, na_sentinel]):将对象编码为枚举类型或分类变量。

Index.identical(other):equals类似,但检查其他可比属性是否相等

Index.insert(loc, item):使新索引在位置插入新项目。

Index.is_(other):更灵活,更快速的检查,is但通过视图工作

Index.is_boolean():

Index.is_categorical():检查索引是否包含分类数据。

Index.is_floating():

Index.is_integer():

Index.is_interval():

Index.is_lexsorted_for_tuple(tup):

Index.is_mixed():

Index.is_numeric():

Index.is_object():

Index.min():返回索引的最小值。

Index.max():返回索引的最大值。

Index.reindex(target[, method, level, …]):使用目标值创建索引(根据需要移动/添加/删除值)

Index.rename(name[, inplace]):在索引上设置新名称。

Index.repeat(repeats, *args, **kwargs):重复索引的元素。

Index.where(cond[, other]):版本0.19.0中的新功能。

Index.take(indices[, axis, allow_fill, …]):返回索引选择的值的新索引

Index.putmask(mask, value):返回使用掩码设置的值的新索引

Index.set_names(names[, level, inplace]):在索引上设置新名称。

Index.unique([level]):返回索引中的唯一值。

Index.nunique([dropna]):返回对象中唯一元素的数量。

Index.value_counts([normalize, sort, …]):返回包含唯一值计数的对象。

缺少值

Index.fillna([value, downcast]):使用指定值填充NA / NaN

Index.dropna([how]):返回没有NA / NaN值的索引

Index.isna():检测缺失值。

Index.notna():检测现有(非缺失)值

转换

Index.astype(dtype[, copy]):使用强制转换为dtypes的值创建索引。

Index.item():将基础数据的第一个元素作为python标量返回

Index.map(mapper[, na_action]):使用输入对应(字典,系列或函数)映射值。

Index.ravel([order]):返回基础数据的扁平值的ndarray

Index.tolist():返回值列表。

Index.to_native_types([slicer]):格式化self指定值并返回它们。

Index.to_series([index, name]):创建一个索引和值等于索引键的系列,该索引键对map用于根据索引返回索引器

Index.to_frame([index]):使用包含索引的列创建DataFrame

排序

Index.argsort(*args, **kwargs):返回将对索引进行排序的整数指标

Index.searchsorted(value[, side, sorter]):查找应插入元素以维护顺序的索引

Index.sort_values([return_indexer, ascending]):返回索引的排序副本

特定时间的操作

Index.shift([periods, freq]):按所需的时间频率增量数移动索引.

组合/ 加入/ 设置操作

Index.append(other):一起附加索引选项的集合

Index.join(other[, how, level, …]):这是一种内部非公开方法

Index.intersection(other):形成两个Index对象的交集。

Index.union(other):如果可能,形成两个Index对象的联合和排序。

Index.difference(other):返回包含索引中不在其他元素中的元素的新索引。

Index.symmetric_difference(other[, result_name]):计算两个Index对象的对称差异

选择

Index.asof(label):对于排序索引,返回最新标签,包括传递的标签。

Index.asof_locs(where, mask):其中:timestamps数组mask:数据不是NA的布尔数组

Index.contains(key):如果此键在索引中,则返回布尔值

Index.get_duplicates():DEPRECATED)提取重复的索引元素。

Index.get_indexer(target[, method, limit, …]):给定当前索引计算新索引的索引器和掩码。

Index.get_indexer_for(target, **kwargs):即使在非唯一时也保证返回索引器这将调整到get_indexerget_indexer_nonunique

Index.get_indexer_non_unique(target):给定当前索引计算新索引的索引器和掩码。

Index.get_level_values(level):返回请求级别的值索引,等于索引的长度。

Index.get_loc(key[, method, tolerance]):获取所请求标签的整数位置,切片或布尔掩码。

Index.get_slice_bound(label, side, kind):计算与给定标签对应的切片边界。

Index.get_value(series, key):1ndarray快速查找值。

Index.get_values():索引数据作为numpy.ndarray返回。

Index.set_value(arr, key, value):1ndarray快速查找值。

Index.isin(values[, level]):返回一个布尔数组,其中索引值为value

Index.slice_indexer([start, end, step, kind]):对于有序或唯一索引,请计算输入标签和步骤的切片索引器。

Index.slice_locs([start, end, step, kind]):计算输入标签的切片位置。

Numeric Index

RangeIndex不可变指数实现单调整数范围。

Int64Index不可变的ndarray实现有序的可切片集。

UInt64Index不可变的ndarray实现有序的可切片集。

Float64Index不可变的ndarray实现有序的可切片集。

RangeIndex.from_range(data[, name, dtype]):从范围(py3)或xrangepy2)对象创建RangeIndex

分类

CategoricalIndex:不可变索引实现有序的可切片集

分类组件

CategoricalIndex.rename_categories(*args, …):重命名类别。

CategoricalIndex.reorder_categories(*args, …):重新排序new_categories中指定的类别。

CategoricalIndex.add_categories(*args, **kwargs):添加新类别。

CategoricalIndex.remove_categories(*args, …):删除指定的类别。

CategoricalIndex.remove_unused_categories(…):删除未使用的类别。

CategoricalIndex.set_categories(*args, **kwargs):将类别设置为指定的new_categories

CategoricalIndex.as_ordered(*args, **kwargs):设置要排序的分类

CategoricalIndex.as_unordered(*args, **kwargs):Categorical设置为无序

CategoricalIndex.map(mapper):使用输入对应(字典,系列或函数)映射值。

IntervalIndex

IntervalIndex不可变索引实现有序的可切片集.

IntervalIndex Components

IntervalIndex.from_arrays(left, right[, …]):从定义左边界和右边界的两个数组构造。

IntervalIndex.from_tuples(data[, closed, …]):从元组的列表/数组构造IntervalIndex

IntervalIndex.from_breaks(breaks[, closed, …]):从一组拆分构造一个IntervalIndex

IntervalIndex.contains(key):返回一个布尔值,指示键是否在索引中

IntervalIndex.leftIntervalIndex中每个Interval的左端点作为索引返回

IntervalIndex.rightIntervalIndex中每个Interval的右端点作为索引返回

IntervalIndex.midIntervalIndex中每个Interval的中点作为索引返回

IntervalIndex.closed是否在左侧,右侧,两者或两者都关闭间隔

IntervalIndex.length返回一个索引,其中的条目表示IntervalIndex中每个Interval的长度

IntervalIndex.valuesIntervalIndex的数据作为Interval对象的numpy数组返回(使用dtype ='object'

IntervalIndex.is_non_overlapping_monotonic如果IntervalIndex不重叠(没有间隔共享点)并且是单调递增或单调递减,则返回True,否则返回False

IntervalIndex.get_loc(key[, method]):获取所请求标签的整数位置,切片或布尔掩码。

IntervalIndex.get_indexer(target[, method, …]):给定当前索引计算新索引的索引器和掩码。

多指标

MultiIndex用于pandas对象的多级或分层索引对象

IndexSlice创建一个对象以更轻松地执行多索引切片

MultiIndex 构造函数

MultiIndex.from_arrays(arrays[, sortorder, …]):将数组转换为MultiIndex

MultiIndex.from_tuples(tuples[, sortorder, …]):将元组列表转换为MultiIndex

MultiIndex.from_product(iterables[, …]):从多个迭代的笛卡尔积中创建一个MultiIndex

MultiIndex 属性

MultiIndex.namesMultiIndex中的级别名称

MultiIndex.levels

MultiIndex.labels

MultiIndex.nlevelsMultiIndex中的整数级别。

MultiIndex.levshape每个级别长度的元组。

MultiIndex 组件

MultiIndex.set_levels(levels[, level, …]):MultiIndex上设置新级别。

MultiIndex.set_labels(labels[, level, …]):MultiIndex上设置新标签。

MultiIndex.to_hierarchical(n_repeat[, n_shuffle]):返回重新整形的MultiIndex以符合n_repeatn_shuffle给出的形状。

MultiIndex.to_frame([index]):使用MultiIndex的级别作为列创建DataFrame

MultiIndex.is_lexsorted():如果标签按字典顺序排序,则返回True

MultiIndex.sortlevel([level, ascending, …]):按要求的级别对MultiIndex进行排序。

MultiIndex.droplevel([level]):已删除请求级别的返回索引。

MultiIndex.swaplevel([i, j]):交换等级i与等级j

MultiIndex.reorder_levels(order):使用输入顺序重新排列级别。

MultiIndex.remove_unused_levels():从当前删除未使用的级别创建一个新的MultiIndex,这意味着它们不会在标签中表示

MultiIndex.unique([level]):返回索引中的唯一值。

MultiIndex 选择

MultiIndex.get_loc(key[, method]):获取标签或标签元组的位置作为整数,切片或布尔掩码。

MultiIndex.get_indexer(target[, method, …]):给定当前索引计算新索引的索引器和掩码。

MultiIndex.get_level_values(level):返回请求级别的标签值向量,等于索引的长度

DatetimeIndex

DatetimeIndexdatetime64数据的不可变ndarray,内部表示为int64,可以装入Timestamp对象,这些对象是datetime的子类,并携带元数据,如频率信息.

选择时间/日期组件

DatetimeIndex.year日期时间

DatetimeIndex.month月份为1= 112= 12

DatetimeIndex.day日期时间的日子

DatetimeIndex.hour日期时间

DatetimeIndex.minute日期时间的分钟

DatetimeIndex.second日期时间的秒数

DatetimeIndex.microsecond日期时间的微秒

DatetimeIndex.nanosecond日期时间的纳秒

DatetimeIndex.date返回numpy数组的python datetime.date对象(即没有时区信息的Timestamps的日期部分)。

DatetimeIndex.time返回datetime.timenumpy数组。

DatetimeIndex.dayofyear一年中的序数日

DatetimeIndex.weekofyear一年中的一周序数

DatetimeIndex.week一年中的一周序数

DatetimeIndex.dayofweek星期一= 0,星期日= 6的星期几

DatetimeIndex.weekday星期一= 0,星期日= 6的星期几

DatetimeIndex.quarter日期的四分之一

DatetimeIndex.tz

DatetimeIndex.freq如果已设置,则返回频率对象,否则返回None

DatetimeIndex.freqstr如果设置了频率对象,则将其作为字符串返回,否则为None

DatetimeIndex.is_month_start逻辑指示是否每月的第一天(由频率定义)

DatetimeIndex.is_month_end指示日期是否是该月的最后一天。

DatetimeIndex.is_quarter_start指示日期是否是一个季度的第一天。

DatetimeIndex.is_quarter_end指示日期是否是一个季度的最后一天。

DatetimeIndex.is_year_start指明日期是否是一年的第一天。

DatetimeIndex.is_year_end指明日期是一年中的最后一天。

DatetimeIndex.is_leap_year布尔指示符,如果日期属于闰年。

 

DatetimeIndex.inferred_freq尝试返回表示由infer_freq生成的频率猜测的字符串

选择

DatetimeIndex.indexer_at_timetime[asof]):返回特定时刻的索引值的索引位置(例如,

 

DatetimeIndex.indexer_between_time... [...]):返回值的特定时间之间的值的索引位置(例如,900-930AM)。

 

特定时间的操作

DatetimeIndex.normalize():将时间转换为午夜。

DatetimeIndex.strftime(date_format):使用指定的date_format转换为Index

DatetimeIndex.snap([freq]):将时间戳记录到最近出现的频率

DatetimeIndex.tz_convert(tz):tz-aware DatetimeIndex从一个时区转换为另一个时区。

DatetimeIndex.tz_localize(tz[, ambiguous, …]):tz-naive DatetimeIndex本地化为tz-aware DatetimeIndex

DatetimeIndex.round(freq, *args, **kwargs):将数据舍入到指定的频率

DatetimeIndex.floor(freq):将数据置于指定的频率

DatetimeIndex.ceil(freq):将数据ceil到指定的频率

DatetimeIndex.month_name([locale]):返回具有指定语言环境的DateTimeIndex的月份名称。

 

DatetimeIndex.day_name([locale]):返回具有指定语言环境的DateTimeIndex的日期名称。

转换

DatetimeIndex.to_period([freq]):以特定频率转换为PeriodIndex

DatetimeIndex.to_perioddelta(freq):计算索引值与指定频率下转换为periodIndex的索引之间差异的TimedeltaIndex

DatetimeIndex.to_pydatetime():返回DatetimeIndex作为datetime.datetime对象的对象ndarray

DatetimeIndex.to_series([keep_tz, index, name]):创建一个索引和值等于索引键的系列,该索引键对map用于根据索引返回索引器

DatetimeIndex.to_frame([index]):使用包含索引的列创建DataFrame

TimedeltaIndex

TimedeltaIndex:timedelta64数据的不可变ndarray,内部表示为int64,可以装入timedelta对象

ConversionComponents

TimedeltaIndex.days:每个元素的天数。

TimedeltaIndex.seconds:每个元素的秒数(> = 0且小于1天)。

TimedeltaIndex.microseconds:每个元素的微秒数(> = 0且小于1秒)。

TimedeltaIndex.nanoseconds:每个元素的纳秒数(> = 0且小于1微秒)。

TimedeltaIndex.components:返回Timedeltas的组件(天,小时,分钟,秒,毫秒,微秒,纳秒)的数据帧。

 

TimedeltaIndex.inferred_freq:尝试返回表示由infer_freq生成的频率猜测的字符串。

转换

TimedeltaIndex.to_pytimedelta():返回TimedeltaIndex作为datetime.timedelta对象的对象ndarray

TimedeltaIndex.to_series([index, name]):创建一个索引和值等于索引键的系列,该索引键对map用于根据索引返回索引器

TimedeltaIndex.round(freq, *args, **kwargs):将数据舍入到指定的频率

TimedeltaIndex.floor(freq):将数据置于指定的频率

TimedeltaIndex.ceil(freq):将数据ceil到指定的频率

TimedeltaIndex.to_frame([index]):使用包含索引的列创建DataFrame

PeriodIndex

PeriodIndex:不可变的ndarray持有序数值,表示特定的时间段,如特定的年,季度,月等

属性

PeriodIndex.day:这段时期

PeriodIndex.dayofweek:星期一= 0,星期日= 6的星期几

PeriodIndex.dayofyear:一年中的序数日

PeriodIndex.days_in_month:本月的天数

PeriodIndex.daysinmonth:本月的天数

PeriodIndex.end_time

PeriodIndex.freq:如果已设置,则返回频率对象,否则返回None

PeriodIndex.freqstr:如果设置了频率对象,则将其作为字符串返回,否则为None

PeriodIndex.hour:这段时间

PeriodIndex.is_leap_year:逻辑指示日期是否属于闰年

PeriodIndex.minute:这段时间的一分钟

PeriodIndex.month:月份为1= 112= 12

PeriodIndex.quarter:日期的四分之一

PeriodIndex.qyear

PeriodIndex.second:第二个时期

PeriodIndex.start_time

PeriodIndex.week:一年中的一周序数

PeriodIndex.weekday:星期一= 0,星期日= 6的星期几

PeriodIndex.weekofyear:一年中的一周序数

 

PeriodIndex.year:这一年的一年

Methods

PeriodIndex.asfreq([freq, how]):PeriodIndex转换为指定的频率freq

PeriodIndex.strftime(date_format):使用指定的date_format转换为Index

PeriodIndex.to_timestamp([freq, how]):转换为DatetimeIndex

PeriodIndex.tz_convert(tz):tz-aware DatetimeIndex从一个时区转换为另一个时区(使用pytz / dateutil

PeriodIndex.tz_localize(tz[, ambiguous]):tz-naive DatetimeIndex本地化为给定时区(using pytz/dateutil),或从tz-aware DatetimeIndex中删除时区

标量

Period

Period代表一段时间

属性

Period.day:获取某个时段所在月份的某一天。

Period.dayofweek:返回星期几。

Period.dayofyear:返回一年中的某一天。

Period.days_in_month:获取此期间所在月份的总天数。

Period.daysinmonth:获取该期间所在月份的总天数。

Period.end_time

Period.freq

Period.freqstr

Period.hour:获取期间的小时组成部分。

Period.is_leap_year

Period.minute:获取期间的小时部分。

Period.month

Period.ordinal

Period.quarter

Period.qyear

Period.second:获取期间的第二个组成部分。

Period.start_time:获取期间开始的时间戳。

Period.week:获取给定期间的一年中的一周。

Period.weekday

Period.weekofyear

 

Period.year

方法

Period.asfreq将周期转换为所需频率,在间隔的开始或结束时

Period.now

Period.strftime返回的字符串表示形式Period,具体取决于所选的fmt

Period.to_timestampPeriodTimestamp表示返回到Period的指定末尾(how)的目标频率

时间戳

Timestamp:Pandas 替换 for datetime.datetime

方法

Timestamp.astimezonetz-aware Timestamp转换为另一个时区。

Timestamp.ceil返回一个新的时间戳,该时间戳已通过此决议

Timestamp.combine(date, time):datetime - > datetime,具有相同的日期和时间字段

Timestamp.ctime返回ctime()样式字符串。

Timestamp.date返回具有相同年,月和日的日期对象。

Timestamp.day_name返回具有指定语言环境的时间戳的日期名称。

Timestamp.dst返回self.tzinfo.dst(自我)。

Timestamp.floor返回一个覆盖此分辨率的新时间戳

Timestamp.freq

Timestamp.freqstr

Timestamp.fromordinal(ordinal[, freq, tz]):传递了序数,翻译并转换为ts音符:根据定义,序数本身不能有任何tz信息

Timestamp.fromtimestamp(ts):timestamp [tz] - > tz来自POSIX时间戳的本地时间。

Timestamp.isocalendar返回包含ISO年份,周数和工作日的3元组。

Timestamp.isoformat

Timestamp.isoweekday返回日期所代表的星期几。

Timestamp.month_name返回具有指定语言环境的时间戳的月份名称。

Timestamp.normalize将时间戳标准化为午夜,保留tz信息。

Timestamp.now([tz]):返回表示tz本地当前时间的新Timestamp对象。

Timestamp.replace实现datetime.replace,处理纳秒

Timestamp.round将时间戳舍入为指定的分辨率

Timestamp.strftimeformat - > strftime()样式字符串。

Timestamp.strptimestringformat - >从字符串解析的新日期时间(如time.strptime())。

Timestamp.time同时返回时间对象但是tzinfo = None

Timestamp.timestampPOSIX时间戳返回为float

Timestamp.timetuple返回时间元组,与time.localtime()兼容。

Timestamp.timetz同时返回时间对象和tzinfo

Timestamp.to_datetime64返回具有'ns'精度的numpy.datetime64对象

Timestamp.to_julian_dateTimeStamp转换为Julian日期。

Timestamp.to_period返回此时间戳为观察值的时段。

Timestamp.to_pydatetimeTimestamp对象转换为本机Python datetime对象。

Timestamp.today(cls[, tz]):返回当地时区的当前时间。

Timestamp.toordinal返回预感格里高利序数。

Timestamp.tz_converttz-aware Timestamp转换为另一个时区。

Timestamp.tz_localize将天真时间戳转换为本地时区,或从tz感知时间戳中删除时区。

Timestamp.tzname返回self.tzinfo.tzname(个体经营)。

Timestamp.utcfromtimestamp(ts):POSIX时间戳构造一个天真的UTC日期时间。

Timestamp.utcnow():返回表示UTC日期和时间的新时间戳。

Timestamp.utcoffset返回self.tzinfo.utcoffset(个体经营)。

Timestamp.utctimetuple返回UTC时间元组,与time.localtime()兼容。

Timestamp.weekday返回日期所代表的星期几。

间隔

Interval不可变对象实现Interval,有界切片状间隔.

属性

Interval.closed是否在左侧,右侧,两侧或两者都关闭间隔

Interval.closed_left检查左侧是否关闭间隔。

Interval.closed_right检查右侧是否关闭间隔。

Interval.left左边界限

Interval.length返回Interval的长度

Interval.mid返回间隔的中点

Interval.open_left检查左侧是否打开间隔。

Interval.open_right检查右侧是否打开间隔。

 

Interval.right右边界限

Timedelta

Timedelta表示持续时间,两个日期或时间之间的差异

属性

Timedelta.asm8:返回我自己的numpy timedelta64数组视图

Timedelta.components:返回与NamedTuple类似的组件

Timedelta.days:天数。

Timedelta.delta:以纳秒(ns)为单位返回timedelta,以获得内部兼容性。

Timedelta.freq

Timedelta.is_populated

Timedelta.max

Timedelta.microseconds:微秒数(> = 0且小于1秒)。

Timedelta.min

Timedelta.nanoseconds:返回纳秒数(n),其中0 <= n <1微秒。

Timedelta.resolution:返回表示我们拥有的最低分辨率的字符串

Timedelta.seconds:秒数(> = 0且不到1天)。

Timedelta.value

Timedelta.view:数组视图compat

方法

Timedelta.ceil:返回一个新的Timedelta以此决议

Timedelta.floor:返回一个新的Timedelta,落在这个分辨率上

Timedelta.isoformat:将Timedelta格式化为ISO 8601持续时间P[n]Y[n]M[n]DT[n]H[n]M[n]S,其中[n]s由值替换。

Timedelta.round:将Timedelta四舍五入到指定的分辨率

Timedelta.to_pytimedelta:返回一个实际的datetime.timedelta对象注释:如果有的话,我们将失去纳秒分辨率

Timedelta.to_timedelta64:返回具有'ns'精度的numpy.timedelta64对象

Timedelta.total_secondstimedelta的总持续时间,以秒为单位(以ns精度计)

频率

to_offset(freq):从字符串或元组表示或datetime.timedelta对象返回DateOffset对象

窗口

滚动物体被返回.rolling电话:pandas.DataFrame.rolling()pandas.Series.rolling(),等扩展对象通过返回.expanding的呼叫:pandas.DataFrame.expanding()pandas.Series.expanding(),等EWM对象通过返回.ewm的呼叫:pandas.DataFrame.ewm()pandas.Series.ewm(),等.

标准移动窗口函数

Rolling.count():窗口内任何非NaN观测值的滚动计数。

Rolling.sum(*args, **kwargs):计算给定DataFrameSeries的滚动总和。

Rolling.mean(*args, **kwargs):计算值的滚动平均值。

Rolling.median(**kwargs):计算滚动中位数。

Rolling.var([ddof]):计算无偏滚动方差。

Rolling.std([ddof]):计算滚动标准偏差。

Rolling.min(*args, **kwargs):计算滚动最小值。

Rolling.max(*args, **kwargs):滚动最大值

Rolling.corr([other, pairwise]):滚动样本相关性

Rolling.cov([other, pairwise, ddof]):滚动样本协方差

Rolling.skew(**kwargs):无偏见的滚动偏度

Rolling.kurt(**kwargs):计算无偏滚动峰度。

Rolling.apply(func[, raw, args, kwargs]):滚动功能适用

Rolling.aggregate(arg, *args, **kwargs):使用指定轴上的一个或多个操作进行聚合。

Rolling.quantile(quantile[, interpolation]):滚动分位数。

Window.mean(*args, **kwargs):计算值的窗口均值。

 

Window.sum(*args, **kwargs):计算给定DataFrameSeries的窗口总和。

标准扩展窗口函数

Expanding.count(**kwargs):窗口内任何非NaN观测值的扩展计数。

Expanding.sum(*args, **kwargs):计算给定DataFrameSeries的扩展和。

Expanding.mean(*args, **kwargs):计算值的扩展平均值。

Expanding.median(**kwargs):计算扩展中位数。

Expanding.var([ddof]):计算无偏扩展方差。

Expanding.std([ddof]):计算扩展标准偏差。

Expanding.min(*args, **kwargs):计算扩展的最小值。

Expanding.max(*args, **kwargs):扩大最大化

Expanding.corr([other, pairwise]):扩大样本相关性

Expanding.cov([other, pairwise, ddof]):扩展样本协方差

Expanding.skew(**kwargs):不偏不倚地扩大偏斜

Expanding.kurt(**kwargs):计算无偏扩张峰度。

Expanding.apply(func[, raw, args, kwargs]):扩展功能适用

Expanding.aggregate(arg, *args, **kwargs):使用指定轴上的一个或多个操作进行聚合。

 

Expanding.quantile(quantile[, interpolation]):扩大分位数。

指数加权移动窗口函数

EWM.mean(*args, **kwargs):指数加权移动平均线

EWM.std([bias]):指数加权移动stddev

EWM.var([bias]):指数加权移动方差

EWM.corr([other, pairwise]):指数加权样本相关

EWM.cov([other, pairwise, bias]):指数加权样本协方差

GroupBy

GroupBy objects are returned by groupby calls: pandas.DataFrame.groupby()pandas.Series.groupby(), etc.

索引, 迭代

GroupBy.__iter__():Groupby迭代器

GroupBy.groups:dict {组名 - >组标签}

GroupBy.indices:dict {组名 - >组索引}

GroupBy.get_group(name[, obj]):从提供名称的组构造NDFrame

Grouper([key, level, freq, axis, sort]):Grouper允许用户为目标对象指定groupby指令

功能应用

GroupBy.apply(func, *args, **kwargs):func 分组应用功能并将结果组合在一起.

GroupBy.aggregate(func, *args, **kwargs): 

GroupBy.transform(func, *args, **kwargs): 

GroupBy.pipe(func, *args, **kwargs):将func带有参数的函数应用于此GroupBy对象并返回函数的结果.

计算/ 描述性统计

GroupBy.all([skipna]):如果组中的所有值都是真实的,则返回True,否则返回False

GroupBy.any([skipna]):如果组中的任何值是真实的,则返回True,否则返回False

GroupBy.bfill([limit]):向后填充值

GroupBy.count():计算组的计数,不包括缺失值

GroupBy.cumcount([ascending]):将每个组中的每个项目编号从0到该组的长度 - 1

GroupBy.ffill([limit]):向前填充值

GroupBy.first(**kwargs):首先计算组值

GroupBy.head([n]):返回每组的前n行。

GroupBy.last(**kwargs):计算最后一组值

GroupBy.max(**kwargs):计算组值的最大值

GroupBy.mean(*args, **kwargs):计算组的平均值,不包括缺失值

GroupBy.median(**kwargs):计算组的中位数,排除缺失值

GroupBy.min(**kwargs):计算组值的最小值

GroupBy.ngroup([ascending]):将每个组的编号从0到组的​​数量 - 1

GroupBy.nth(n[, dropna]):如果nint,则从每个组中取第n;如果nint列表,则从行的子集获取。

GroupBy.ohlc():计算值的总和,不包括缺失值对于多个分组,结果索引将是MultiIndex

GroupBy.prod(**kwargs):计算组值的产品

GroupBy.rank([method, ascending, na_option, …]):提供每个组中的值的等级。

GroupBy.pct_change([periods, fill_method, …]):计算每个值的pct_change到组中的上一个条目

GroupBy.size():计算组大小

GroupBy.sem([ddof]):计算组平均值的标准误差,排除缺失值

GroupBy.std([ddof]):计算组的标准偏差,不包括缺失值

GroupBy.sum(**kwargs):计算组值的总和

GroupBy.var([ddof]):计算组的方差,排除缺失值

 

GroupBy.tail([n]):返回每组的最后n

 

以下方法在两个对象SeriesGroupBy和 DataFrameGroupBy对象中都可用,但可能略有不同,通常是因为DataFrameGroupBy版本通常允许指定axis参数,并且通常是指示是否将应用程序限制为特定数据类型的列的参数.

DataFrameGroupBy.agg(arg, *args, **kwargs):使用指定轴上的一个或多个操作进行聚合。

DataFrameGroupBy.all([skipna]):如果组中的所有值都是真实的,则返回True,否则返回False

DataFrameGroupBy.any([skipna]):如果组中的任何值是真实的,则返回True,否则返回False

DataFrameGroupBy.bfill([limit]):向后填充值

DataFrameGroupBy.corr计算列的成对相关性,不包括NA / null

DataFrameGroupBy.count():计算组的计数,不包括缺失值

DataFrameGroupBy.cov计算列的成对协方差,不包括NA / null值。

DataFrameGroupBy.cummax([axis]):每组累积最大值

DataFrameGroupBy.cummin([axis]):每组累积最小值

DataFrameGroupBy.cumprod([axis]):每组的累积产品

DataFrameGroupBy.cumsum([axis]):每组的累计金额

DataFrameGroupBy.describe(**kwargs):生成描述性统计数据,总结数据集分布的集中趋势,分散和形状,不包括NaN值。

DataFrameGroupBy.diff第一个离散的元素差异。

DataFrameGroupBy.ffill([limit]):向前填充值

DataFrameGroupBy.fillna使用指定的方法填充NA / NaN

DataFrameGroupBy.filter(func[, dropna]):返回DataFrame的副本,不包括不满足func指定的布尔标准的组中的元素。

DataFrameGroupBy.hist制作DataFrame的直方图。

DataFrameGroupBy.idxmax返回请求轴上第一次出现最大值的索引。

DataFrameGroupBy.idxmin返回首次出现最小请求轴的索引。

DataFrameGroupBy.mad返回请求轴的值的平均绝对偏差

DataFrameGroupBy.pct_change([periods, …]):计算每个值的pct_change到组中的上一个条目

DataFrameGroupBy.plot实现groupby对象的.plot属性的类

DataFrameGroupBy.quantile在请求的轴上返回给定分位数的值,即la numpy.percentile

DataFrameGroupBy.rank([method, ascending, …]):提供每个组中的值的等级。

DataFrameGroupBy.resample(rule, *args, **kwargs):使用TimeGrouper时提供重新采样返回附加了重新采样器的新石斑鱼

DataFrameGroupBy.shift([periods, freq, axis]):按周期观察移动每组

DataFrameGroupBy.size():计算组大小

DataFrameGroupBy.skew返回请求轴的无偏偏差,由N-1归一化

DataFrameGroupBy.take沿轴返回给定位置索引中的元素。

 

DataFrameGroupBy.tshift如果可用,使用索引的频率来移动时间索引。

以下方法仅适用于SeriesGroupBy对象.

SeriesGroupBy.nlargest:返回最大的n元素。

SeriesGroupBy.nsmallest:返回最小的n元素。

SeriesGroupBy.nunique[dropna]):返回组中唯一元素的数量

SeriesGroupBy.unique:返回Series对象的唯一值。

SeriesGroupBy.value_counts[normalize...]):

SeriesGroupBy.is_monotonic_increasing:如果对象中的值是monotonic_increasing,则返回布尔值

 

SeriesGroupBy.is_monotonic_decreasing:如果对象中的值是monotonic_decreasing,则返回布尔值

以下方法仅适用于DataFrameGroupBy对象.

DataFrameGroupBy.corrwith计算两个DataFrame对象的行或列之间的成对关联.

DataFrameGroupBy.boxplot([subplots, column, …]):DataFrameGroupBy数据制作箱形图.

重新采样

重新采样对象由resample调用返回: pandas.DataFrame.resample()pandas.Series.resample().

索引, 迭代

Resampler.__iter__():Groupby迭代器

Resampler.groups:dict {组名 - >组标签}

Resampler.indices:dict {组名 - >组索引}

Resampler.get_group(name[, obj]):从提供名称的组构造NDFrame

功能应用

Resampler.apply(arg, *args, **kwargs):使用指定轴上的一个或多个操作进行聚合。

Resampler.aggregate(arg, *args, **kwargs):使用指定轴上的一个或多个操作进行聚合。

Resampler.transform(arg, *args, **kwargs):调用函数在每个组上生成类似索引的Series,并返回带有转换值的Series

Resampler.pipe(func, *args, **kwargs):将func带有参数的函数应用于此Resampler对象并返回函数的结果。

上采样

Resampler.ffill([limit]):向前填充值

Resampler.backfill([limit]):向后填充重新采样数据中的新缺失值。

Resampler.bfill([limit]):向后填充重新采样数据中的新缺失值。

Resampler.pad([limit]):向前填充值

Resampler.nearest([limit]):从中心开始用最近邻居填充值

Resampler.fillna(method[, limit]):填写上采样引入的缺失值。

Resampler.asfreq([fill_value]):返回新频率的值,基本上是一个reindex

Resampler.interpolate([method, axis, limit, …]):根据不同的方法插值。

计算/ 描述性统计

Resampler.count([_method]):计算组的计数,不包括缺失值

Resampler.nunique([_method]):返回组中唯一元素的数量

Resampler.first([_method]):首先计算组值

Resampler.last([_method]):计算最后一组值

Resampler.max([_method]):计算组值的最大值

Resampler.mean([_method]):计算组的平均值,不包括缺失值

Resampler.median([_method]):计算组的中位数,排除缺失值

Resampler.min([_method]):计算组值的最小值

Resampler.ohlc([_method]):计算值的总和,不包括缺失值对于多个分组,结果索引将是MultiIndex

Resampler.prod([_method, min_count]):计算组值的产品

Resampler.size():计算组大小

Resampler.sem([_method]):计算组平均值的标准误差,排除缺失值

Resampler.std([ddof]):计算组的标准偏差,不包括缺失值

Resampler.sum([_method, min_count]):计算组值的总和

Resampler.var([ddof]):计算组的方差,排除缺失值

Style

Styler objects are returned by pandas.DataFrame.style.

Styler 构造函数

Styler(data[, precision, table_styles, …]):根据HTML和CSS的数据帮助设置DataFrame或Series的样式.

Styler.from_custom_template(searchpath, name):用于创建Styler具有自定义模板和Jinja环境的子类的工厂函数.

Styler 属性

Styler.env  
Styler.template  
Styler.loader  

风格应用

Styler.apply(func[, axis, subset]):按列,按行或按行应用函数,使用结果更新HTML表示。

Styler.applymap(func[, subset]):元素应用函数,使用结果更新HTML表示。

Styler.where(cond, value[, other, subset]):元素应用函数,使用根据函数的返回值选择的样式更新HTML表示。

Styler.format(formatter[, subset]):格式化单元格的文本显示值。

Styler.set_precision(precision):设置用于渲染的精度。

Styler.set_table_styles(table_styles):在Styler上设置表格样式。

Styler.set_table_attributes(attributes):设置表属性。

Styler.set_caption(caption):在样式器上设置标题

Styler.set_properties([subset]):用于设置一个或多个非数据相关属性或每个单元的便捷方法。

Styler.set_uuid(uuid):为Styler设置uuid。

Styler.clear():“重置”样式器,删除任何以前应用的样式。

内置样式

Styler.highlight_max([subset, color, axis]):通过着色背景突出显示最大值

Styler.highlight_min([subset, color, axis]):通过着色背景突出显示最小值

Styler.highlight_null([null_color]):null_color为缺失值着色背景。

Styler.background_gradient([cmap, low, …]):根据每列(可选行)中的数据为渐变中的背景着色。

Styler.bar([subset, axis, color, width, align]):将背景颜色设置color为每列中的值。

样式导出和导入

Styler.render(**kwargs):将构建的样式呈现为HTML

Styler.export():导出要应用于当前Styler的样式。

Styler.use(styles):在当前Styler上设置样式,可能使用样式Styler.export。

Styler.to_excel(excel_writer[, sheet_name, …]):将Styler写入Excel工作表

绘图

pandas.plotting模块中包含以下函数。

andrews_curves(frame, class_column[, ax, …]):生成安德鲁斯曲线的matplotlib图,用于可视化多元数据的聚类。

bootstrap_plot(series[, fig, size, samples]):关于均值,中位数和中位数统计的Bootstrap图。

deregister_matplotlib_converters():删除pandas的格式化程序和转换器

lag_plot(series[, lag, ax]):时间序列的滞后图。

parallel_coordinates(frame, class_column[, …]):平行坐标绘图。

radviz(frame, class_column[, ax, color, …]):在2D中绘制多维数据集。

register_matplotlib_converters([explicit]):使用matplotlib注册Pandas格式化程序和转换器

scatter_matrix(frame[, alpha, figsize, ax, …]):绘制散点图矩阵。

一般实用功能

使用选项

describe_option(pat[, _print_desc]):打印一个或多个已注册选项的说明。

reset_option(pat):将一个或多个选项重置为其默认值。

get_option(pat):检索指定选项的值。

set_option(pat, value):设置指定选项的值。

option_context(*args):上下文管理器临时设置with语句上下文中的选项。

测试功能

testing.assert_frame_equal(left, right[, …]):检查左右DataFrame是否相等。

testing.assert_series_equal(left, right[, …]):检查左右系列是否相等。

testing.assert_index_equal(left, right[, …]):检查左右索引是否相等。

例外 and 警告

errors.DtypeWarning:从文件中读取列中的不同dtypes时出现警告。

errors.EmptyDataError:遇到空数据或标头时,在pd.read_csv(由C和Python引擎引发)中抛出的异常。

errors.OutOfBoundsDatetime

errors.ParserErrorpd.read_csv遇到的错误引发的异常。

errors.ParserWarning:读取不使用默认“c”解析器的文件时引发警告。

errors.PerformanceWarning:出现可能的性能影响时发出警告。

errors.UnsortedIndexError:尝试获取MultiIndex切片时出错,并且索引尚未被lexsorted。

errors.UnsupportedFunctionCall:尝试在pandas对象上调用numpy函数时引发异常,但该对象不支持该函数,例如

数据类型相关功能

api.types.union_categoricals(to_union[, …]):结合列表类似类别,联合类别。

api.types.infer_dtype:有效地推断传递的val或类似列表的数组的类型。

api.types.pandas_dtype(dtype):将输入转换为仅pandas的dtype对象或numpy dtype对象。

Dtype内省

api.types.is_bool_dtype(arr_or_dtype):检查提供的数组或dtype是否为布尔dtype。

api.types.is_categorical_dtype(arr_or_dtype):检查类似数组或dtype是否属于Categorical dtype。

api.types.is_complex_dtype(arr_or_dtype):检查提供的数组或dtype是否为复杂的dtype。

api.types.is_datetime64_any_dtype(arr_or_dtype):检查提供的数组或dtype是否为datetime64 dtype。

api.types.is_datetime64_dtype(arr_or_dtype):检查数组类型或dtype是否为datetime64 dtype。

api.types.is_datetime64_ns_dtype(arr_or_dtype):检查提供的数组或dtype是否为datetime64 [ns] dtype。

api.types.is_datetime64tz_dtype(arr_or_dtype):检查数组类型或dtype是否为DatetimeTZDtype dtype。

api.types.is_extension_type(arr):检查类似数组是否是pandas扩展类实例。

api.types.is_float_dtype(arr_or_dtype):检查提供的数组或dtype是否为float dtype。

api.types.is_int64_dtype(arr_or_dtype):检查提供的数组或dtype是否为int64 dtype。

api.types.is_integer_dtype(arr_or_dtype):检查提供的数组或dtype是否为整数dtype。

api.types.is_interval_dtype(arr_or_dtype):检查数组类型或dtype是否为Interval dtype。

api.types.is_numeric_dtype(arr_or_dtype):检查提供的数组或dtype是否为数字dtype。

api.types.is_object_dtype(arr_or_dtype):检查数组类型或dtype是否为对象dtype。

api.types.is_period_dtype(arr_or_dtype):检查数组类型或dtype是否为Period dtype。

api.types.is_signed_integer_dtype(arr_or_dtype):检查提供的数组或dtype是否为带符号整数dtype。

api.types.is_string_dtype(arr_or_dtype):检查提供的数组或dtype是否为字符串dtype。

api.types.is_timedelta64_dtype(arr_or_dtype):检查数组类型或dtype是否属于timedelta64 dtype。

api.types.is_timedelta64_ns_dtype(arr_or_dtype):检查提供的数组或dtype是否为timedelta64 [ns] dtype。

api.types.is_unsigned_integer_dtype(arr_or_dtype):检查提供的数组或dtype是否为无符号整数dtype。

api.types.is_sparse(arr):检查数组是否是pandas稀疏数组。

可迭代的内省

api.types.is_dict_like(obj):检查对象是否像dict一样。

api.types.is_file_like(obj):检查对象是否是类文件对象。

api.types.is_list_like(obj):检查对象是否类似于列表。

api.types.is_named_tuple(obj):检查对象是否是命名元组。

api.types.is_iterator(obj):检查对象是否是迭代器。

标量内省

api.types.is_bool

api.types.is_categorical(arr):检查类似数组是否是分类实例。

api.types.is_complex

api.types.is_datetimetz(arr):检查类似数组是否与日期时间数组一样,其dtype中包含时区组件。

api.types.is_float

api.types.is_hashable(obj):如果hash(obj)成功则返回True,否则返回False。

api.types.is_integer

api.types.is_interval

api.types.is_number(obj):检查对象是否为数字。

api.types.is_period(arr):检查类似数组是否是一个周期性索引。

api.types.is_re(obj):检查对象是否是正则表达式模式实例。

api.types.is_re_compilable(obj):检查对象是否可以编译为正则表达式模式实例。

api.types.is_scalar:如果给定值是标量,则返回True。

扩展

这些主要用于寻求扩展pandas对象的图书馆作者.

api.extensions.register_dataframe_accessor(name):在DataFrame对象上注册自定义访问器。

api.extensions.register_series_accessor(name):在Series对象上注册自定义访问器。

api.extensions.register_index_accessor(name):在Index对象上注册自定义访问器。

api.extensions.ExtensionDtype:自定义数据类型,与ExtensionArray配对。

api.extensions.ExtensionArray:自定义1-D数组类型的抽象基类。

 

http://pandas.pydata.org/pandas-docs/stable/api.html

GroupBy.all([skipna]):如果组中的所有值都是真实的,则返回True,否则返回False

GroupBy.any([skipna]):如果组中的任何值是真实的,则返回True,否则返回False

GroupBy.bfill([limit]):向后填充值

GroupBy.count():计算组的计数,不包括缺失值

GroupBy.cumcount([ascending]):将每个组中的每个项目编号从0到该组的长度 - 1

GroupBy.ffill([limit]):向前填充值

GroupBy.first(**kwargs):首先计算组值

GroupBy.head([n]):返回每组的前n行。

GroupBy.last(**kwargs):计算最后一组值

GroupBy.max(**kwargs):计算组值的最大值

GroupBy.mean(*args, **kwargs):计算组的平均值,不包括缺失值

GroupBy.median(**kwargs):计算组的中位数,排除缺失值

GroupBy.min(**kwargs):计算组值的最小值

GroupBy.ngroup([ascending]):将每个组的编号从0到组的​​数量 - 1

GroupBy.nth(n[, dropna]):如果nint,则从每个组中取第n;如果nint列表,则从行的子集获取。

GroupBy.ohlc():计算值的总和,不包括缺失值对于多个分组,结果索引将是MultiIndex

GroupBy.prod(**kwargs):计算组值的产品

GroupBy.rank([method, ascending, na_option, …]):提供每个组中的值的等级。

GroupBy.pct_change([periods, fill_method, …]):计算每个值的pct_change到组中的上一个条目

GroupBy.size():计算组大小

GroupBy.sem([ddof]):计算组平均值的标准误差,排除缺失值

GroupBy.std([ddof]):计算组的标准偏差,不包括缺失值

GroupBy.sum(**kwargs):计算组值的总和

GroupBy.var([ddof]):计算组的方差,排除缺失值

GroupBy.tail([n]):返回每组的最后n

猜你喜欢

转载自blog.csdn.net/qq_35883464/article/details/86596910