I'm attempting to use the itemfreq() function from scipy to count the frequencies of unique elements in numpy arrays.
Basically, I've declared a variable (let's call it "A") that outputs a numpy array. Depending on earlier inputs, "A" may contain anywhere from 0 to 13 elements. When "A" contains at least 1 element, the itemfreq() functions works perfectly, but if "A" is empty, I get the following error:
IndexError: index out of bounds.
I'd like to be able to write a simple statement like this:
if A = []: print ("Sorry, your array is empty")
else: print (itemfreq(A))
But I'm not sure how to say that first line of code ("if A is an empty array") in python-speak.
Thanks!