I have a numpy array that I need to consolidate by combining the rows with duplicate entries (based on the first column), while preserving any positive values of the other columns. My array looks like this.
array([[117, 0, 1, 0, 0, 0],
[163, 1, 0, 0, 0, 0],
[117, 0, 0, 0, 0, 1],
[120, 0, 1, 0, 0, 0],
[189, 0, 0, 0, 1, 0],
[117, 1, 0, 0, 0, 0],
[120, 0, 0, 1, 0, 0]])
I'm trying to make the output look like this:
array([[117, 1, 1, 0, 0, 1],
[120, 0, 1, 1, 0, 0],
[163, 1, 0, 0, 0, 0],
[189, 0, 0, 0, 1, 0]])
I've been able to use unique on column zero to filter out the duplicates, but I can't seem to preserve the values of the other columns. I would appreciate any input!
117, 120, 163, 189)?