How to Fix Error return arrays must be of arraytype

from math import log
import xlrd
***# from numpy import ****
import operator

def calcShannonEnt(dataSet):#calculata shannonEnt
    numEntries = len(dataSet)
    labelCounts = {}
    for featVec in dataSet:#Add the current key value to the dictionary and record the number of occurrences of the category
        currentLabel = featVec[-1]
        if currentLabel not in labelCounts.keys():
            labelCounts[currentLabel] = 0
        labelCounts[currentLabel] += 1
    shannonEnt = 0.0
    for key in labelCounts:#Calculating Shannon entropy
        prob = float(labelCounts[key])/numEntries#Calculate the probability of category occurrence using the frequency of occurrence of all class labels
        tmp = prob*log(prob,2)
        shannonEnt -= tmp#Get Shannon entropy
    return shannonEnt

Typeerror: return arrays must be of array-type occurs when the code is running, because the second parameter of log is not base but out array. If you just want to perform normal log operations, you can choose to use numpy.math.log (1.1, 2) or use the log function of math module in Python instead of importing all the functions TT in numpy

Read More: