mcfred
mcfred

Reputation: 1391

Python array stores boolean value as an array

I have the following python code which compares two numbers and stores either true or false in the array. However, in stead of storing it like this:

 [True, False, True....]

It stores it like this:

[array([ True]), array([ False]), array([ True])]

Here's the code:

def runSample(file_name):
    samples=open(file_name,'r').readlines()
    result=[]
    check = False
    for line in samples:
        data=json.loads(line);
        check=data[-1]==clf.predict([data[:-1]])
        result.append(check)
    print(result)

Upvotes: 0

Views: 205

Answers (1)

pjk
pjk

Reputation: 556

Try

if check is not None:
    result.extend(check)

This will add check items to result

Upvotes: 3

Related Questions