Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'else:': 0.03; 'suggestions,': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'terry': 0.09; 'message- id:@dough.gmane.org': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'row': 0.16; 'wrote:': 0.17; 'jan': 0.18; 'equivalent': 0.20; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; 'header:X-Complaints- To:1': 0.28; 'lines': 0.28; 'subject:data': 0.33; 'to:addr:python- list': 0.33; 'thanks': 0.34; 'pm,': 0.35; 'received:org': 0.36; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'end': 0.40; 'skip:u 10': 0.60; 'email addr:gmail.com': 0.63; 'believe': 0.69; 'received:fios.verizon.net': 0.84; 'yours': 0.88 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: no data exclution and unique combination. Date: Thu, 09 Aug 2012 17:33:58 -0400 References: <864b0104-daa8-4ea5-8003-6cfaab19fdea@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20120713 Thunderbird/14.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1344548070 news.xs4all.nl 6937 [2001:888:2000:d::a6]:38494 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:26816 On 8/9/2012 4:06 PM, giuseppe.amatulli@gmail.com wrote: > Terry and MRAB, > thanks for yours suggestions, > in the end i found this solution > > > mask=( a != 0 ) & ( b != 0 ) > > a_mask=a[mask] > b_mask=b[mask] > > array2D = np.array(zip(a_mask,b_mask)) > > unique=dict() > for row in array2D : > row = tuple(row) > if row in unique: > unique[row] += 1 > else: > unique[row] = 1 I believe the 4 lines above are equivalent to unique[row] = unique.get(row, 0) + 1 -- Terry Jan Reedy