Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #26816
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: no data exclution and unique combination. |
| Date | 2012-08-09 17:33 -0400 |
| References | <864b0104-daa8-4ea5-8003-6cfaab19fdea@googlegroups.com> <bccc20ed-7570-4e15-980c-008987ce0361@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3121.1344548070.4697.python-list@python.org> (permalink) |
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
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