Jan-14-2020, 10:02 AM
[inline]import numpy as np
person_data_def = [('name', 'm8'),('height', 'f8'),('weight', 'f8'),('age', 'i8')]
people_array = np.zeros(4, dtype=person_data_def)
print(people_array)
people_array[0] = ('delta', 73, 300, 38)
print(people_array)[/inline]
person_data_def = [('name', 'm8'),('height', 'f8'),('weight', 'f8'),('age', 'i8')]
people_array = np.zeros(4, dtype=person_data_def)
print(people_array)
people_array[0] = ('delta', 73, 300, 38)
print(people_array)[/inline]
Output:[(0, 0., 0., 0) (0, 0., 0., 0) (0, 0., 0., 0) (0, 0., 0., 0)]
Error:Traceback (most recent call last):
File "C:/Users/user/PycharmProjects/test/test2.py", line 5, in <module>
people_array[0] = ('delta', 73, 300, 38)
ValueError: Could not convert object to NumPy timedelta