Assume there is a numpy contains the following data structure:
import numpy as np
a = np.array([['2','W','A'],
['3', 'R', 'A'],
['4', 'W', 'R'],
['2', 'E', 'R'],
['4', 'E', 'Y'],
['3', 'E', 'Y']])
- Need to summarize the appearance number of unique instances in the third column and return numpy so that it returns the following result:
[['A' '2']
['R' '2']
['Y' '2']]
(For example the value of A
appears in the third column twice, so the result will be 'A' '2'
.)
- Similarly, sum the unique values found in both the second and third columns and return numpy in the following structure:
[['W' 'A' '1']
['R' 'A' '1']
['W' 'R' '1']
['E' 'R' '1']
['E' 'Y' '2']
For example the value of E
in the second column together with the value of Y
in the third column appears twice, so the result will be 'E' 'Y' '2'
.