Write a NumPy program to create an array of zeros and three column types (integer, float, character)

  • برمجة بايثون

Write a NumPy program to create an array of zeros and three column types (integer, float, character)

الأجوبة

import numpy as np
x = np.zeros((3,), dtype=('i4,f4,a40'))
new_data = [(1, 2., "Albert Einstein"), (2, 2., "Edmond Halley"), (3, 3., "Gertrude B. Elion")]
x[:] = new_data
print(x)

Sample Output:

[(1,  2., b'Albert Einstein') (2,  2., b'Edmond Halley')               
 (3,  3., b'Gertrude B. Elion')]
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...