okay Todd, I got it. There are some reasons why I preferred asking that question. Let me explain:
I am using Excel data which contains 3 columns and say 12 rows to process some simple data. What I want to do with the code you provided is that In the first column A has data that indicates the same ID where 2nd and 3rd has the same value. In other words I will put the following sample data to explain better: A_column = [ 22, 92, 64, 64, 77, 77, 64, 64, 22, 92, 99, 200 ] # The same length 12 B_column = [ 8, 8, 8, 8, 8, 0, 0, 0, 0, 0, 12, 0] # The same length 12 C_column = [ 0, 0, 0, 0, 0, 8, 8, 8, 8, 8, 4, 13] # The same length 12 The main reason for the question is as we discussed we already processed data in A_column. B_column has five "8" numbers in C_column as well but not in the same index!!! I want to get the following result which really confused me in terms of 'dtype': IF A_column the same THEN The value of B_column and C_columns in the ID (index, we got) is the same THEN get B and C value otherwise NO... I hope you would understand my problem Среда, 17 апреля 2013, 12:34 +02:00 от Todd < [email protected] >: >>The data type: >>x in ndarray and x[ i ]--> int64 >>type(f) --> ' list ' >>type( f[ 0 ] ) --> ' tuple ' >>type( f[ 0][0] ) --> 'ndarray' >>type( f[ 0 ][ 0 ][ 0] ) --> 'int64' >> >>How do you think to avoid diversity if data type in this example? I think it is not necessary to get diverse dtype as well as more than 1D array.. >That is why I suggested this approach was better ( note the that this is >where()[0] instead of just where() as it was in my first example): > >x,i=numpy.unique(y, return_inverse=True) >f=[numpy.where(i==ind)[0] for ind in range(len(x))] > >type(f) --> list >type(f[0]) --> ndarray > >type(f[0][0]) is meaningless since it is just a single element in an array. >It must be an int type of some sort of since indices have to be int types. x >will be the same dtype as your input array. > >You could conceivably change the type of f[0] to a list, but why would you >want to? One of the big advantages of python is that usually it doesn't >matter what the type is. In this case, a numpy ndarray will work the same as >a list in most cases where you would want to use these sorts of indices. It is >possibly to change the ndarray to a list, but unless there is a specific >reason you need to use lists so then it is better not to. > >You cannot change the list to an ndarray because the elements of the list are >different lengths. ndarray doesn't support that. >_______________________________________________ >NumPy-Discussion mailing list >[email protected] > http://mail.scipy.org/mailman/listinfo/numpy-discussion > _______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
