python - TypeError in Numpy when using custom datatype -
I'm learning using ". However, I get this error in an assignment:
TypeError: A readable buffer object is expected This is my code:
record = DTEP ([('name', 'SR_', 40), ('stock', 'int 32'), ('value', 'float 32')] item = array (['Book A', 5, 29.95], DTP = record)
By using the Numpy array, you should make a list of tuples, rather it should be a topless list. The Neptemi array is hopeful of a list of Tupals, hopefully, the solution to your problem is low.
& gt; & Gt; & Gt; Np & gt; & Gt; & Gt; Record = np.dtype ([('name', 'str_', 40), ('stock', 'int32'), ('price', 'float32')]> gt; & Gt; & Gt; Var = [('Book A', 5, 29.95)]> gt; & Gt; & Gt; Item = np Array (var, dtype = record)> gt; & Gt; & Gt; Item array ('(Book A', 5, 29.950000762939453)], dtype = [('name', '| S40'), ('stock', '' i4 ''), ('price', '& lt ; F4 ')]) gt; & Gt; & Gt;
Comments
Post a Comment