pandas_py3k.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:packaging 作者: blockstack 项目源码 文件源码
def __and__(self, other):
        ''' Intersection is the minimum of corresponding counts.

        >>> Counter('abbb') & Counter('bcc')
        Counter({'b': 1})

        '''
        if not isinstance(other, Counter):
            return NotImplemented
        _min = min
        result = Counter()
        if len(self) < len(other):
            self, other = other, self
        for elem in filter(self.__contains__, other):
            newcount = _min(self[elem], other[elem])
            if newcount > 0:
                result[elem] = newcount
        return result
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号