'<' not supported between instances of 'numpy.ndarray' and 'str' while jsonify dict

97 views Asked by At

I am getting below error while jsonify.

TypeError: '<' not supported between instances of 'numpy.ndarray' and 'str'

My code is:

if rows[0]:
        print("row1",rows[1])
        #data_json = str(rows[1])
        data_json = jsonify(rows[1])

Expecting Json object but getting error.

1

There are 1 answers

0
AboAmmar On

jsonify only accepts dictionaries, lists, and primitive data types as input. Convert the numpy.ndarray to a list and then pass it to jsonify.

if rows[0]:
        print("row1",rows[1])
        data_json = jsonify(rows[1].tolist())