本文整理汇总了Python中blaze.expr.Symbol.nelements方法的典型用法代码示例。如果您正苦于以下问题:Python Symbol.nelements方法的具体用法?Python Symbol.nelements怎么用?Python Symbol.nelements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blaze.expr.Symbol
的用法示例。
在下文中一共展示了Symbol.nelements方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_nelements_array
# 需要导入模块: from blaze.expr import Symbol [as 别名]
# 或者: from blaze.expr.Symbol import nelements [as 别名]
def test_nelements_array():
t = Symbol('t', '5 * 4 * 3 * float64')
x = np.random.randn(*t.shape)
result = compute(t.nelements(axis=(0, 1)), x)
np.testing.assert_array_equal(result, np.array([20, 20, 20]))
result = compute(t.nelements(axis=1), x)
np.testing.assert_array_equal(result, 4 * np.ones((5, 3)))
示例2: test_nelements_records
# 需要导入模块: from blaze.expr import Symbol [as 别名]
# 或者: from blaze.expr.Symbol import nelements [as 别名]
def test_nelements_records(recdata):
s = Symbol('s', discover(recdata))
assert compute(s.nelements(), recdata) == np.prod(recdata.shape)
np.testing.assert_array_equal(compute(s.nelements(axis=0), recdata),
np.zeros(recdata.shape[1]) + recdata.shape[0])
示例3: by
# 需要导入模块: from blaze.expr import Symbol [as 别名]
# 或者: from blaze.expr.Symbol import nelements [as 别名]
by(t.name, t.amount.sum()): [],
by(t.id, t.id.count()): [],
by(t[['id', 'amount']], t.id.count()): [],
by(t[['id', 'amount']], (t.amount + 1).sum()): [mongo],
by(t[['id', 'amount']], t.name.nunique()): [mongo],
by(t.id, t.amount.count()): [],
by(t.id, t.id.nunique()): [mongo],
# by(t, t.count()): [],
# by(t.id, t.count()): [df],
t[['amount', 'id']]: [x], # https://github.com/numpy/numpy/issues/3256
t[['id', 'amount']]: [x, bc], # bcolz sorting
t[0]: [sql, mongo],
t[::2]: [sql, mongo],
t.id.utcfromtimestamp: [sql],
t.distinct().nrows: [],
t.nelements(axis=0): [],
t.nelements(axis=None): []
}
base = df
def df_eq(a, b):
return (list(a.columns) == list(b.columns)
and list(a.dtypes) == list(b.dtypes)
and into(set, into(list, a)) == into(set, into(list, b)))
def typename(obj):
return type(obj).__name__