本文整理汇总了Python中pandas.compat.reduce方法的典型用法代码示例。如果您正苦于以下问题:Python compat.reduce方法的具体用法?Python compat.reduce怎么用?Python compat.reduce使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandas.compat
的用法示例。
在下文中一共展示了compat.reduce方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: visit_BoolOp
# 需要导入模块: from pandas import compat [as 别名]
# 或者: from pandas.compat import reduce [as 别名]
def visit_BoolOp(self, node, **kwargs):
def visitor(x, y):
lhs = self._try_visit_binop(x)
rhs = self._try_visit_binop(y)
op, op_class, lhs, rhs = self._maybe_transform_eq_ne(
node, lhs, rhs)
return self._maybe_evaluate_binop(op, node.op, lhs, rhs)
operands = node.values
return reduce(visitor, operands)
# ast.Call signature changed on 3.5,
# conditionally change which methods is named
# visit_Call depending on Python version, #11097
示例2: _format_header
# 需要导入模块: from pandas import compat [as 别名]
# 或者: from pandas.compat import reduce [as 别名]
def _format_header(self):
if isinstance(self.columns, ABCMultiIndex):
gen = self._format_header_mi()
else:
gen = self._format_header_regular()
gen2 = ()
if self.df.index.names:
row = [x if x is not None else ''
for x in self.df.index.names] + [''] * len(self.columns)
if reduce(lambda x, y: x and y, map(lambda x: x != '', row)):
gen2 = (ExcelCell(self.rowcounter, colindex, val,
self.header_style)
for colindex, val in enumerate(row))
self.rowcounter += 1
return itertools.chain(gen, gen2)
示例3: should_warn
# 需要导入模块: from pandas import compat [as 别名]
# 或者: from pandas.compat import reduce [as 别名]
def should_warn(*args):
not_mono = not any(map(operator.attrgetter('is_monotonic'), args))
only_one_dt = reduce(operator.xor, map(_is_datetime, args))
return not_mono and only_one_dt
示例4: _compose
# 需要导入模块: from pandas import compat [as 别名]
# 或者: from pandas.compat import reduce [as 别名]
def _compose(*funcs):
"""Compose 2 or more callables"""
assert len(funcs) > 1, 'At least 2 callables must be passed to compose'
return reduce(_compose2, funcs)
示例5: _result_type_many
# 需要导入模块: from pandas import compat [as 别名]
# 或者: from pandas.compat import reduce [as 别名]
def _result_type_many(*arrays_and_dtypes):
""" wrapper around numpy.result_type which overcomes the NPY_MAXARGS (32)
argument limit """
try:
return np.result_type(*arrays_and_dtypes)
except ValueError:
# we have > NPY_MAXARGS terms in our expression
return reduce(np.result_type, arrays_and_dtypes)
示例6: compose
# 需要导入模块: from pandas import compat [as 别名]
# 或者: from pandas.compat import reduce [as 别名]
def compose(*funcs):
"""Compose 2 or more callables"""
assert len(funcs) > 1, 'At least 2 callables must be passed to compose'
return reduce(_compose2, funcs)
示例7: _format_header
# 需要导入模块: from pandas import compat [as 别名]
# 或者: from pandas.compat import reduce [as 别名]
def _format_header(self):
if isinstance(self.columns, MultiIndex):
gen = self._format_header_mi()
else:
gen = self._format_header_regular()
gen2 = ()
if self.df.index.names:
row = [x if x is not None else ''
for x in self.df.index.names] + [''] * len(self.columns)
if reduce(lambda x, y: x and y, map(lambda x: x != '', row)):
gen2 = (ExcelCell(self.rowcounter, colindex, val, header_style)
for colindex, val in enumerate(row))
self.rowcounter += 1
return itertools.chain(gen, gen2)
示例8: visit_BoolOp
# 需要导入模块: from pandas import compat [as 别名]
# 或者: from pandas.compat import reduce [as 别名]
def visit_BoolOp(self, node, **kwargs):
def visitor(x, y):
lhs = self._try_visit_binop(x)
rhs = self._try_visit_binop(y)
op, op_class, lhs, rhs = self._possibly_transform_eq_ne(node, lhs,
rhs)
return self._possibly_evaluate_binop(op, node.op, lhs, rhs)
operands = node.values
return reduce(visitor, operands)
示例9: chain_dot
# 需要导入模块: from pandas import compat [as 别名]
# 或者: from pandas.compat import reduce [as 别名]
def chain_dot(*matrices):
"""
Returns the dot product of the given matrices.
Parameters
----------
matrices: argument list of ndarray
"""
return reduce(lambda x, y: np.dot(y, x), matrices[::-1])
示例10: _should_parse
# 需要导入模块: from pandas import compat [as 别名]
# 或者: from pandas.compat import reduce [as 别名]
def _should_parse(self, i, parse_cols):
def _range2cols(areas):
"""
Convert comma separated list of column names and column ranges to a
list of 0-based column indexes.
>>> _range2cols('A:E')
[0, 1, 2, 3, 4]
>>> _range2cols('A,C,Z:AB')
[0, 2, 25, 26, 27]
"""
def _excel2num(x):
"Convert Excel column name like 'AB' to 0-based column index"
return reduce(lambda s, a: s * 26 + ord(a) - ord('A') + 1,
x.upper().strip(), 0) - 1
cols = []
for rng in areas.split(','):
if ':' in rng:
rng = rng.split(':')
cols += lrange(_excel2num(rng[0]), _excel2num(rng[1]) + 1)
else:
cols.append(_excel2num(rng))
return cols
if isinstance(parse_cols, int):
return i <= parse_cols
elif isinstance(parse_cols, compat.string_types):
return i in _range2cols(parse_cols)
else:
return i in parse_cols
示例11: __init__
# 需要导入模块: from pandas import compat [as 别名]
# 或者: from pandas.compat import reduce [as 别名]
def __init__(self, gbls=None, lcls=None, level=1, resolvers=None,
target=None):
self.level = level
self.resolvers = tuple(resolvers or [])
self.globals = dict()
self.locals = dict()
self.target = target
self.ntemps = 1 # number of temporary variables in this scope
if isinstance(lcls, Scope):
ld, lcls = lcls, dict()
self.locals.update(ld.locals.copy())
self.globals.update(ld.globals.copy())
self.resolvers += ld.resolvers
if ld.target is not None:
self.target = ld.target
self.update(ld.level)
frame = sys._getframe(level)
try:
self.globals.update(gbls or frame.f_globals)
self.locals.update(lcls or frame.f_locals)
finally:
del frame
# add some useful defaults
self.globals['Timestamp'] = pd.lib.Timestamp
self.globals['datetime'] = datetime
# SUCH a hack
self.globals['True'] = True
self.globals['False'] = False
# function defs
self.globals['list'] = list
self.globals['tuple'] = tuple
res_keys = (list(o.keys()) for o in self.resolvers)
self.resolver_keys = frozenset(reduce(operator.add, res_keys, []))
self._global_resolvers = self.resolvers + (self.locals, self.globals)
self._resolver = None
self.resolver_dict = {}
for o in self.resolvers:
self.resolver_dict.update(dict(o))