数据框#

构造函数#

DataFrame([data, index, columns, dtype, ...])

一个GPU数据框对象。

属性和基础数据#

坐标轴

DataFrame.axes

返回一个表示DataFrame轴线的列表。

DataFrame.index

获取行的标签。

DataFrame.columns

返回列的元组

DataFrame.dtypes

返回此对象中的数据类型。

DataFrame.info([verbose, buf, max_cols, ...])

打印DataFrame的简明摘要。

DataFrame.select_dtypes([include, exclude])

根据列的数据类型返回DataFrame列的子集。

DataFrame.values

返回DataFrame的CuPy表示。

DataFrame.ndim

数据的维度。

DataFrame.size

返回基础数据中的元素数量。

DataFrame.shape

返回一个表示DataFrame维度的元组。

DataFrame.memory_usage([index, deep])

返回对象的内存使用情况。

DataFrame.empty

指示DataFrame或Series是否为空。

转换#

DataFrame.astype(dtype[, copy, errors])

将对象转换为指定的数据类型。

DataFrame.convert_dtypes([infer_objects, ...])

将列转换为最佳可能的可空数据类型。

DataFrame.copy([deep])

复制此对象的索引和数据。

索引,迭代#

DataFrame.head([n])

返回前 n 行。

DataFrame.at

DataFrame.loc 的别名;提供与 Pandas 的兼容性。

DataFrame.iat

DataFrame.iloc 的别名;提供与 Pandas 的兼容性。

DataFrame.loc

通过标签或布尔掩码选择行和列。

DataFrame.iloc

按位置选择值。

DataFrame.insert(loc, column, value[, ...])

在由loc指定的索引处向DataFrame添加一列。

DataFrame.__iter__()

DataFrame.items()

遍历列名和系列对

DataFrame.keys()

获取列。

DataFrame.iterrows()

不支持迭代。

DataFrame.itertuples([index, name])

不支持迭代。

DataFrame.pop(item)

返回一列并将其从DataFrame中删除。

DataFrame.tail([n])

返回最后n行作为新的DataFrame或Series

DataFrame.isin(values)

DataFrame中的每个元素是否包含在values中。

DataFrame.squeeze([axis])

将一维轴对象压缩为标量。

DataFrame.where(cond[, other, inplace, ...])

替换条件为False的值。

DataFrame.mask(cond[, other, inplace, axis, ...])

替换条件为True的值。

DataFrame.query(expr[, local_dict])

使用布尔表达式查询,使用Numba编译GPU内核。

二元运算符函数#

DataFrame.add(other[, axis, level, fill_value])

获取DataFrame或Series与其他元素的逐元素加法(二元运算符add)。

DataFrame.sub(other[, axis, level, fill_value])

获取DataFrame或Series与其他元素的逐元素减法(二元运算符sub)。

DataFrame.subtract(other[, axis, level, ...])

获取DataFrame或Series与其他元素的逐元素减法(二元运算符sub)。

DataFrame.mul(other[, axis, level, fill_value])

获取DataFrame或Series与其他元素的逐元素乘法(二元运算符mul)。

DataFrame.multiply(other[, axis, level, ...])

获取DataFrame或Series与其他元素的逐元素乘法(二元运算符mul)。

DataFrame.truediv(other[, axis, level, ...])

获取DataFrame或Series与其他的浮点除法,逐元素操作(二元运算符truediv)。

DataFrame.div(other[, axis, level, fill_value])

获取DataFrame或Series与其他的浮点除法,逐元素进行(二元运算符truediv)。

DataFrame.divide(other[, axis, level, ...])

获取DataFrame或Series与其他的浮点除法,逐元素(二元运算符truediv)。

DataFrame.floordiv(other[, axis, level, ...])

获取DataFrame或Series与其他的整数除法,逐元素(二元运算符floordiv)。

DataFrame.mod(other[, axis, level, fill_value])

获取DataFrame或Series与其他的模,逐元素(二元操作符mod)。

DataFrame.pow(other[, axis, level, fill_value])

获取DataFrame或Series与其他的指数,逐元素(二元运算符pow)。

DataFrame.dot(other[, reflect])

获取框架与其他的点积(二元运算符 dot)。

DataFrame.radd(other[, axis, level, fill_value])

获取DataFrame或Series与其他元素的加法,逐元素(二元运算符radd)。

DataFrame.rsub(other[, axis, level, fill_value])

获取DataFrame或Series与其他元素的减法,逐元素(二元运算符rsub)。

DataFrame.rmul(other[, axis, level, fill_value])

获取DataFrame或Series与其他的逐元素乘法(二元运算符rmul)。

DataFrame.rdiv(other[, axis, level, fill_value])

获取DataFrame或Series与其他的浮点除法,逐元素(二元运算符rtruediv)。

DataFrame.rtruediv(other[, axis, level, ...])

获取DataFrame或Series与其他的浮点除法,逐元素(二元运算符rtruediv)。

DataFrame.rfloordiv(other[, axis, level, ...])

获取DataFrame或Series与其他元素的整数除法,逐元素进行(二元运算符rfloordiv)。

DataFrame.rmod(other[, axis, level, fill_value])

获取DataFrame或Series与其他的模运算,逐元素进行(二元运算符rmod)。

DataFrame.rpow(other[, axis, level, fill_value])

获取DataFrame或Series与其他的指数,逐元素(二元运算符rpow)。

DataFrame.round([decimals, how])

四舍五入到指定的小数位数。

DataFrame.lt(other[, axis, level, fill_value])

获取DataFrame或Series与其他元素的逐元素小于比较(二元运算符lt)。

DataFrame.gt(other[, axis, level, fill_value])

获取DataFrame或Series与其他元素的逐元素大于比较(二元运算符gt)。

DataFrame.le(other[, axis, level, fill_value])

获取DataFrame或Series与其他元素的逐元素小于或等于(二元运算符le)。

DataFrame.ge(other[, axis, level, fill_value])

获取DataFrame或Series与其他元素的逐元素大于或等于(二元运算符ge)。

DataFrame.ne(other[, axis, level, fill_value])

获取DataFrame或Series与其他元素的逐元素不等比较(二元运算符ne)。

DataFrame.eq(other[, axis, level, fill_value])

获取DataFrame或Series与其他的元素级相等(二元操作符eq)。

DataFrame.product([axis, skipna, dtype, ...])

返回DataFrame中值的乘积。

函数应用、分组及窗口#

DataFrame.agg(aggs[, axis])

使用一个或多个操作在指定的轴上进行聚合。

DataFrame.apply(func[, axis, raw, ...])

沿着DataFrame的轴应用一个函数。

DataFrame.applymap(func[, na_action])

对Dataframe的每个元素应用一个函数。

DataFrame.apply_chunks(func, incols, outcols)

使用用户提供的函数转换用户指定的块。

DataFrame.apply_rows(func, incols, outcols, ...)

应用一个逐行的用户定义函数。

DataFrame.groupby([by, axis, level, ...])

使用映射器或一系列列进行分组。

DataFrame.map(func[, na_action])

对Dataframe的每个元素应用一个函数。

DataFrame.pipe(func, *args, **kwargs)

应用 func(self, *args, **kwargs)

DataFrame.rolling(window[, min_periods, ...])

滚动窗口计算。

计算 / 描述性统计#

DataFrame.abs()

返回一个包含每个元素绝对值的Series/DataFrame。

DataFrame.all([axis, bool_only, skipna])

返回DataFrame中所有元素是否为True。

DataFrame.any([axis, bool_only, skipna])

返回DataFrame中是否有任何元素为True。

DataFrame.clip([lower, upper, axis, inplace])

在输入阈值处修剪值。

DataFrame.corr([method, min_periods, ...])

计算DataFrame的相关矩阵。

DataFrame.count([axis, numeric_only])

计算每列或每行的非NA单元格数量。

DataFrame.cov([min_periods, ddof, numeric_only])

计算DataFrame的协方差矩阵。

DataFrame.cummax([axis])

返回IndexedFrame的累积最大值。

DataFrame.cummin([axis])

返回IndexedFrame的累积最小值。

DataFrame.cumprod([axis])

返回IndexedFrame的累积乘积。

DataFrame.cumsum([axis])

返回IndexedFrame的累积和。

DataFrame.describe([percentiles, include, ...])

生成描述性统计信息。

DataFrame.diff([periods, axis])

元素的一阶离散差分。

DataFrame.eval(expr[, inplace])

评估描述DataFrame列操作的字符串。

DataFrame.ewm([com, span, halflife, alpha, ...])

提供指数加权(EW)函数。

DataFrame.kurt([axis, skipna, numeric_only])

返回样本的Fisher无偏峰度。

DataFrame.kurtosis([axis, skipna, numeric_only])

返回样本的Fisher无偏峰度。

DataFrame.max([axis, skipna, numeric_only])

返回DataFrame中值的最大值。

DataFrame.mean([axis, skipna, numeric_only])

返回请求轴上的值的平均值。

DataFrame.median([axis, skipna, numeric_only])

返回请求轴的值的中位数。

DataFrame.min([axis, skipna, numeric_only])

返回DataFrame中的最小值。

DataFrame.mode([axis, numeric_only, dropna])

获取沿选定轴的每个元素的众数。

DataFrame.pct_change([periods, fill_method, ...])

计算DataFrame中连续元素之间的百分比变化。

DataFrame.prod([axis, skipna, dtype, ...])

返回DataFrame中值的乘积。

DataFrame.product([axis, skipna, dtype, ...])

返回DataFrame中值的乘积。

DataFrame.quantile([q, axis, numeric_only, ...])

返回给定分位数的值。

DataFrame.rank([axis, method, numeric_only, ...])

沿轴计算数值数据的排名(1到n)。

DataFrame.round([decimals, how])

四舍五入到指定的小数位数。

DataFrame.scale()

将值缩放到 [0, 1] 的 float64 范围内

DataFrame.skew([axis, skipna, numeric_only])

返回样本的无偏Fisher-Pearson偏度。

DataFrame.sum([axis, skipna, dtype, ...])

返回DataFrame中值的总和。

DataFrame.std([axis, skipna, ddof, numeric_only])

返回DataFrame的样本标准差。

DataFrame.var([axis, skipna, ddof, numeric_only])

返回DataFrame的无偏方差。

DataFrame.nunique([axis, dropna])

计算指定轴上不同元素的数量。

DataFrame.value_counts([subset, normalize, ...])

返回一个包含DataFrame中唯一行计数的Series。

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

DataFrame.add_prefix(prefix[, axis])

使用字符串 prefix 作为前缀标签。

DataFrame.add_suffix(suffix[, axis])

使用字符串suffix作为后缀标签。

DataFrame.drop([labels, axis, index, ...])

从行或列中删除指定的标签。

DataFrame.drop_duplicates([subset, keep, ...])

返回删除重复行的DataFrame。

DataFrame.duplicated([subset, keep])

返回表示重复行的布尔系列。

DataFrame.equals(other)

测试两个对象是否包含相同的元素。

DataFrame.first(offset)

根据日期偏移选择时间序列数据的初始周期。

DataFrame.head([n])

返回前 n 行。

DataFrame.last(offset)

根据日期偏移选择时间序列数据的最后周期。

DataFrame.reindex([labels, index, columns, ...])

使DataFrame适应新的索引。

DataFrame.rename([mapper, index, columns, ...])

更改列和索引标签。

DataFrame.reset_index([level, drop, ...])

重置DataFrame的索引,或其一个级别。

DataFrame.sample([n, frac, replace, ...])

返回对象轴上项目的随机样本。

DataFrame.searchsorted(values[, side, ...])

查找应插入元素以保持顺序的索引

DataFrame.set_index(keys[, drop, append, ...])

返回一个带有新索引的新DataFrame

DataFrame.repeat(repeats[, axis])

连续重复元素。

DataFrame.tail([n])

返回最后n行作为新的DataFrame或Series

DataFrame.take(indices[, axis])

返回一个包含由indices指定的行的新框架。

DataFrame.tile(count)

将行重复count次以形成一个新的框架。

DataFrame.truncate([before, after, axis, copy])

在某个索引值前后截断Series或DataFrame。

缺失数据处理#

DataFrame.backfill([value, axis, inplace, limit])

Series.fillna() 的同义词,使用 method='bfill'

DataFrame.bfill([value, axis, inplace, ...])

Series.fillna() 的同义词,使用 method='bfill'

DataFrame.dropna([axis, how, thresh, ...])

从列中删除包含空值的行(或列)。

DataFrame.ffill([value, axis, inplace, ...])

Series.fillna() 的同义词,使用 method='ffill'

DataFrame.fillna([value, method, axis, ...])

使用value或指定的method填充空值。

DataFrame.interpolate([method, axis, limit, ...])

在一些点之间插值数据。

DataFrame.isna()

识别缺失值。

DataFrame.isnull()

识别缺失值。

DataFrame.nans_to_nulls()

将nans(如果有的话)转换为nulls

DataFrame.notna()

识别非缺失值。

DataFrame.notnull()

识别非缺失值。

DataFrame.pad([value, axis, inplace, limit])

Series.fillna() 的同义词,使用 method='ffill'

DataFrame.replace([to_replace, value, ...])

to_replace中给定的值替换为value

重塑、排序、转置#

DataFrame.argsort([by, axis, kind, order, ...])

返回将Series值排序的整数索引。

DataFrame.interleave_columns()

将表格中的Series列交错合并为单列。

DataFrame.partition_by_hash(columns, nparts)

通过columns中数据的哈希值对数据框进行分区。

DataFrame.pivot(*, columns[, index, values])

返回由给定索引和列值重新组织的DataFrame。

DataFrame.pivot_table([values, index, ...])

创建一个电子表格样式的数据透视表作为DataFrame。

DataFrame.scatter_by_map(map_index[, ...])

分散到多个数据框中。

DataFrame.sort_values(by[, axis, ascending, ...])

按任一轴的值排序。

DataFrame.sort_index([axis, level, ...])

按标签排序对象(沿轴)。

DataFrame.nlargest(n, columns[, keep])

返回按columns降序排列的前n行。

DataFrame.nsmallest(n, columns[, keep])

返回按columns升序排列的前n行。

DataFrame.swaplevel([i, j, axis])

交换第 i 层和第 j 层。

DataFrame.stack([level, dropna, future_stack])

将指定的层级从列堆叠到索引

DataFrame.unstack([level, fill_value, sort])

将(必须是分层的)索引标签的一个或多个级别进行透视。

DataFrame.melt([id_vars, value_vars, ...])

将DataFrame从宽格式转换为长格式,可选择保留标识符变量。

DataFrame.explode(column[, ignore_index])

将类似列表的每个元素转换为一行,复制索引值。

DataFrame.to_struct([name])

返回由DataFrame的列组成的结构体Series。

DataFrame.T

转置索引和列。

DataFrame.transpose()

转置索引和列。

组合 / 比较 / 连接 / 合并#

DataFrame.assign(**kwargs)

从关键字参数中分配列到DataFrame。

DataFrame.join(other[, on, how, lsuffix, ...])

在索引或键列上与其他DataFrame连接列。

DataFrame.merge(right[, how, on, left_on, ...])

通过执行数据库风格的连接操作,按列或索引合并GPU DataFrame对象。

DataFrame.update(other[, join, overwrite, ...])

使用另一个DataFrame中的非NA值就地修改DataFrame。

序列化 / 输入输出 / 转换#

DataFrame.deserialize(header, frames)

从序列化表示生成对象。

DataFrame.device_deserialize(header, frames)

执行设备端的反序列化任务。

DataFrame.device_serialize()

序列化与设备内存相关的数据和元数据。

DataFrame.from_arrow(table)

将PyArrow表转换为DataFrame。

DataFrame.from_dict(data[, orient, dtype, ...])

从类似数组或字典的字典构造DataFrame。

DataFrame.from_pandas(dataframe[, nan_as_null])

从Pandas DataFrame转换。

DataFrame.from_records(data[, index, ...])

将结构化或记录 ndarray 转换为 DataFrame。

DataFrame.hash_values([method, seed])

计算此列中值的哈希值。

DataFrame.host_deserialize(header, frames)

执行设备端的反序列化任务。

DataFrame.host_serialize()

序列化与主机内存相关的数据和元数据。

DataFrame.serialize()

生成对象的等效可序列化表示。

DataFrame.to_arrow([preserve_index])

转换为 PyArrow 表。

DataFrame.to_dict([orient, into, index])

将DataFrame转换为字典。

DataFrame.to_dlpack()

将cuDF对象转换为DLPack张量。

DataFrame.to_parquet(path[, engine, ...])

将DataFrame写入parquet格式。

DataFrame.to_csv([path_or_buf, sep, na_rep, ...])

将数据框写入csv文件格式。

DataFrame.to_cupy([dtype, copy, na_value])

将Frame转换为CuPy数组。

DataFrame.to_hdf(path_or_buf, key, *args, ...)

使用HDFStore将包含的数据写入HDF5文件。

DataFrame.to_dict([orient, into, index])

将DataFrame转换为字典。

DataFrame.to_json([path_or_buf])

将 cuDF 对象转换为 JSON 字符串。

DataFrame.to_numpy([dtype, copy, na_value])

将Frame转换为NumPy数组。

DataFrame.to_pandas(*[, nullable, arrow_type])

转换为Pandas DataFrame。

DataFrame.to_feather(path, *args, **kwargs)

将DataFrame写入feather格式。

DataFrame.to_records([index, column_dtypes, ...])

转换为numpy的recarray

DataFrame.to_string()

转换为字符串

DataFrame.values

返回DataFrame的CuPy表示。

DataFrame.values_host

返回数据的NumPy表示。