Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.mixmin.net!eweka.nl!hq-usenetpeers.eweka.nl!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.85.MISMATCH!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python': 0.09; 'cleaned': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'solution,': 0.09; 'terry': 0.09; 'wrong,': 0.09; '(3,': 0.16; '4),': 0.16; 'message-id:@dough.gmane.org': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'wrote:': 0.17; 'jan': 0.18; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'plain': 0.27; 'skip:b 30': 0.27; 'header:X-Complaints- To:1': 0.28; 'array': 0.29; 'running': 0.32; 'subject:data': 0.33; 'to:addr:python-list': 0.33; 'hi,': 0.33; 'skip:b 20': 0.34; 'pm,': 0.35; 'received:org': 0.36; 'test': 0.36; 'data': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'skip:a 30': 0.60; 'leaving': 0.62; 'email addr:gmail.com': 0.63; 'discovered': 0.83; 'received:fios.verizon.net': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: no data exclution and unique combination. Date: Tue, 24 Jul 2012 15:32:07 -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:13.0) Gecko/20120614 Thunderbird/13.0.1 In-Reply-To: <864b0104-daa8-4ea5-8003-6cfaab19fdea@googlegroups.com> 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: 40 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1343158362 news.xs4all.nl 6954 [2001:888:2000:d::a6]:41546 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:26005 On 7/24/2012 2:27 PM, giuseppe.amatulli@gmail.com wrote: > Hi, > would like to take eliminate a specific number in an array and its correspondent in an other array, and vice-versa. > > given > > a=np.array([1,2,4,4,5,4,1,4,1,1,2,4]) > b=np.array([1,2,3,5,4,4,1,3,2,1,3,4]) > > no_data_a=1 > no_data_b=2 > > a_clean=array([4,4,5,4,4,4]) > b_clean=array([3,5,4,4,3,4]) As I discovered when running the solution before, your test data are wrong, leaving out 2,3 before the last pair (4,4). Anyway, for those interested in a plain Python solution, without numpy: a=[1,2,4,4,5,4,1,4,1,1,2,4] b=[1,2,3,5,4,4,1,3,2,1,3,4] no_data_a=1 no_data_b=2 a_clean=(4,4,5,4,4,2,4) b_clean=(3,5,4,4,3,3,4) cleaned = list(zip(*(pair for pair in zip(a,b) if pair[0] != no_data_a and pair[1] != no_data_b))) print(cleaned, cleaned == [a_clean, b_clean]) # [(4, 4, 5, 4, 4, 2, 4), (3, 5, 4, 4, 3, 3, 4)] True -- Terry Jan Reedy