เมธอด numpy.degrees() แปลงอาร์เรย์เรเดียนเป็นองศา คล้าย rad2deg() แต่เป็นชื่อเมธอดเก่า พารามิเตอร์ out และ where ควบคุมการเก็บผลลัพธ์
ขั้นตอนการใช้งาน
import numpy as np
สร้างอาร์เรย์เรเดียนและแปลง
arr = np.arange(12.)
res = arr * np.pi / 6
print("Array...\n", arr)
print("\nArray datatype...\n", arr.dtype)
print("\nArray Dimensions...\n", arr.ndim)
print("\nNumber of elements in the Array...\n", arr.size)
print("\nRadian array to degrees...\n", np.degrees(res))
โค้ดตัวอย่างสมบูรณ์
import numpy as np
arr = np.arange(12.)
print("Array...\n", arr)
print("\nOur Array type...\n", arr.dtype)
print("\nOur Array Dimensions...\n", arr.ndim)
print("\nNumber of elements...\n", arr.size)
res = arr * np.pi / 6
print("\nRadian array to degrees...\n", np.degrees(res))
ผลลัพธ์ที่คาดหวัง
Array... [ 0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11.] Our Array type... float64 Our Array Dimensions... 1 Number of elements... 12 Radian array to degrees... [ 0. 30. 60. 90. 120. 150. 180. 210. 240. 270. 300. 330.]