本文整理匯總了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