no data exclution and unique combination.

giuseppe.amatulli at gmail.com giuseppe.amatulli at gmail.com
Tue Jul 24 14:27:05 EDT 2012


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

For the fist task i did

a_No_data_a = a[a != no_data_a]
b_No_data_a = b[a != no_data_a]

b_clean = b_No_data_a[b_No_data_a != no_data_b]
a_clean  = a_No_data_a[a_No_data_a != no_data_b]

but the results are not really stable. 

For the second task 
The np.unique would solve the problem if it can be apply to a two arrays.

Any idea?
thanks in advance 
Giuseppe







More information about the Python-list mailing list