Unexpected behavior when using np.unique with return_counts on a multidimensional array
I'm working through a tutorial and I'm experiencing unexpected behavior when using `np.unique` with the `return_counts` argument on a 2D array..... I expected it to return the unique rows along with their counts, but it seems to be treating the entire row as a single entity, which is not what I want. I'm using NumPy version 1.24.2. Here's a simplified version of my code: ```python import numpy as np data = np.array([[1, 2], [1, 2], [3, 4], [1, 2], [3, 4]]) unique_rows, counts = np.unique(data, axis=0, return_counts=True) print("Unique Rows:", unique_rows) print("Counts:", counts) ``` I assumed that `np.unique` with `axis=0` would let me count how many times each unique row appears, but the output is not what I expected: ``` Unique Rows: [[1 2] [3 4]] Counts: [3 2] ``` This part is fine, but I was hoping to understand if it's possible to also get the counts for individual elements across the rows, not just the rows themselves. For instance, if I want to know how many times the number `1` appears in the entire array, or if I can apply this to each column separately. I've tried reshaping the array and applying `np.unique` separately to each column, but it feels inefficient. Is there a more elegant way to count occurrences of individual elements in a 2D array? Any insights or suggestions would be greatly appreciated! How would you solve this? Any help would be greatly appreciated!