Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #26005
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: no data exclution and unique combination. |
| Date | 2012-07-24 15:32 -0400 |
| References | <864b0104-daa8-4ea5-8003-6cfaab19fdea@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2550.1343158362.4697.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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