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
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)
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
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:
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
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
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
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
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