Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #26005

Re: no data exclution and unique combination.

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 <python-python-list@m.gmane.org>
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 <tjreedy@udel.edu>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2550.1343158362.4697.python-list@python.org> (permalink)
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

Show key headers only | View raw


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


Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

no data exclution and unique combination. giuseppe.amatulli@gmail.com - 2012-07-24 11:27 -0700
  Re: no data exclution and unique combination. MRAB <python@mrabarnett.plus.com> - 2012-07-24 19:51 +0100
  Re: no data exclution and unique combination. MRAB <python@mrabarnett.plus.com> - 2012-07-24 20:08 +0100
  Re: no data exclution and unique combination. Terry Reedy <tjreedy@udel.edu> - 2012-07-24 15:32 -0400
  Re: no data exclution and unique combination. giuseppe.amatulli@gmail.com - 2012-08-09 13:06 -0700
    Re: no data exclution and unique combination. Dave Angel <d@davea.name> - 2012-08-09 17:23 -0400
    Re: no data exclution and unique combination. Terry Reedy <tjreedy@udel.edu> - 2012-08-09 17:33 -0400
      Re: no data exclution and unique combination. Hans Mulder <hansmu@xs4all.nl> - 2012-08-10 10:47 +0200

csiph-web