本文整理汇总了Python中blaze.expr.Symbol.count方法的典型用法代码示例。如果您正苦于以下问题:Python Symbol.count方法的具体用法?Python Symbol.count怎么用?Python Symbol.count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blaze.expr.Symbol
的用法示例。
在下文中一共展示了Symbol.count方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_by_columns
# 需要导入模块: from blaze.expr import Symbol [as 别名]
# 或者: from blaze.expr.Symbol import count [as 别名]
def test_by_columns():
t = Symbol('t', 'var * {name: string, amount: int32, id: int32}')
assert len(by(t['id'], total=t['amount'].sum()).fields) == 2
assert len(by(t['id'], count=t['id'].count()).fields) == 2
print(by(t, count=t.count()).fields)
assert len(by(t, count=t.count()).fields) == 4
示例2: test_reduction
# 需要导入模块: from blaze.expr import Symbol [as 别名]
# 或者: from blaze.expr.Symbol import count [as 别名]
def test_reduction():
t = Symbol('t', 'var * {name: string, amount: int32}')
r = sum(t['amount'])
assert r.dshape in (dshape('int64'),
dshape('{amount: int64}'),
dshape('{amount_sum: int64}'))
assert 'amount' not in str(t.count().dshape)
assert t.count().dshape[0] in (int32, int64)
assert 'int' in str(t.count().dshape)
assert 'int' in str(t.nunique().dshape)
assert 'string' in str(t['name'].max().dshape)
assert 'string' in str(t['name'].min().dshape)
assert 'string' not in str(t.count().dshape)
t = Symbol('t', 'var * {name: string, amount: real, id: int}')
assert 'int' in str(t['id'].sum().dshape)
assert 'int' not in str(t['amount'].sum().dshape)
示例3: test_errors
# 需要导入模块: from blaze.expr import Symbol [as 别名]
# 或者: from blaze.expr.Symbol import count [as 别名]
def test_errors():
t = Symbol('t', 'var * {foo: int}')
with raises(NotImplementedError):
compute_up(by(t, t.count()), 1)
示例4: test_count
# 需要导入模块: from blaze.expr import Symbol [as 别名]
# 或者: from blaze.expr.Symbol import count [as 别名]
def test_count():
t = Symbol('t', '3 * int')
assert compute(t.count(), [1, None, 2]) == 2
示例5: test_count_nan
# 需要导入模块: from blaze.expr import Symbol [as 别名]
# 或者: from blaze.expr.Symbol import count [as 别名]
def test_count_nan():
t = Symbol('t', '3 * ?real')
x = np.array([1.0, np.nan, 2.0])
assert compute(t.count(), x) == 2