Re: no data exclution and unique combination.

2012-08-10 Thread Hans Mulder
On 9/08/12 23:33:58, Terry Reedy wrote: > On 8/9/2012 4:06 PM, giuseppe.amatu...@gmail.com wrote: [...] >> 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 abov

Re: no data exclution and unique combination.

2012-08-09 Thread Terry Reedy
On 8/9/2012 4:06 PM, giuseppe.amatu...@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)

Re: no data exclution and unique combination.

2012-08-09 Thread Dave Angel
On 08/09/2012 04:06 PM, giuseppe.amatu...@gmail.com wrote: > > > print unique > {(4, 5): 1, (5, 4): 1, (4, 4): 2, (2, 3): 1, (4, 3): 2} > > I choose this solution because i could not install "from collections import > Counter". Nothing to install, at least for Python 2.7. collections is in the

Re: no data exclution and unique combination.

2012-08-09 Thread giuseppe . amatulli
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:

Re: no data exclution and unique combination.

2012-07-24 Thread Terry Reedy
On 7/24/2012 2:27 PM, giuseppe.amatu...@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=a

Re: no data exclution and unique combination.

2012-07-24 Thread Ian Kelly
On Jul 24, 2012 12:32 PM, wrote: > after i need to calculate unique combination in pairs to count the observations > and obtain > (4,3,2) > (4,5,1) > (5,4,1) > (4,4,2) I don't know about a numpy solution, but this could be achieved by collections.Counter(zip(a, b)).items(). That gives you: ((4,3

Re: no data exclution and unique combination.

2012-07-24 Thread MRAB
On 24/07/2012 19:51, MRAB wrote: On 24/07/2012 19:27, giuseppe.amatu...@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]) n

Re: no data exclution and unique combination.

2012-07-24 Thread MRAB
On 24/07/2012 19:27, giuseppe.amatu...@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=ar

no data exclution and unique combination.

2012-07-24 Thread giuseppe . amatulli
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]) after i