TableGroups#

class astropy.table.TableGroups(parent_table, indices=None, keys=None)[源代码]#

基类:BaseGroups

属性摘要

indices 

key_colnames 

返回父表中用于分组的列的名称。

keys 

方法总结

aggregate \(函数)

通过应用reduction函数将表中的每个组聚合为一行 func 对每列中的值进行分组。

filter \(函数)

基于求值函数的表中过滤组 func 在每个分组子表上。

属性文档

indices#
key_colnames#

返回父表中用于分组的列的名称。

keys#

方法文件

aggregate(func)[源代码]#

通过应用reduction函数将表中的每个组聚合为一行 func 对每列中的值进行分组。

参数:
func : functionPYTHON:函数

函数,它将值数组缩减为单个值

返回:
out : Table

包含聚合行的新表。

filter(func)[源代码]#

基于求值函数的表中过滤组 func 在每个分组子表上。

传递给此方法的函数必须接受两个参数:

  • tableTable 对象

  • key_colnames :中的列名元组 table 用作分组键

然后它也必须返回 TrueFalse . 例如,下面将选择非键列中只有正值的所有表组:

def all_positive(table, key_colnames):
    colnames = [name for name in table.colnames if name not in key_colnames]
    for colname in colnames:
        if np.any(table[colname] < 0):
            return False
    return True
参数:
func : functionPYTHON:函数

过滤函数

返回:
out : Table

包含聚合行的新表。