numpy.min_scalar() পদ্ধতিটি সর্বনিম্ন ডেটা টাইপ খুঁজে পায়। 1ম প্যারামিটার হল সেই মান যার ন্যূনতম ডেটা টাইপ পাওয়া যায়। স্কেলারের জন্য, ক্ষুদ্রতম আকার এবং ক্ষুদ্রতম স্কেলার ধরণের সাথে ডেটা টাইপ প্রদান করে যা এর মান ধরে রাখতে পারে। নন-স্কেলার অ্যারের জন্য, ভেক্টরের dtype অপরিবর্তিত প্রদান করে। ফ্লোটিং পয়েন্টের মানগুলিকে পূর্ণসংখ্যাতে অবনমিত করা হয় না এবং জটিল মানগুলিকে ফ্লোটে অবনমিত করা হয় না।
পদক্ষেপ
প্রথমে, প্রয়োজনীয় লাইব্রেরি আমদানি করুন -
import numpy as np
numpy.min_scalar() পদ্ধতিটি সর্বনিম্ন ডেটা টাইপ −
খুঁজে পায়print("Using the min_scalar() method in Numpy\n") print("Result...",np.min_scalar_type(55)) print("Result...",np.min_scalar_type(38.9)) print("Result...",np.min_scalar_type(-78)) print("Result...",np.min_scalar_type(479)) print("Result...",np.min_scalar_type(2e100)) print("Result...",np.min_scalar_type(-45.8)) print("Result...",np.min_scalar_type(6.5e100))
উদাহরণ
# For scalar, returns the data type with the smallest size and smallest scalar kind which can hold its value. # For non-scalar array, returns the vector’s dtype unmodified. # Floating point values are not demoted to integers, and complex values are not demoted to floats. import numpy as np # The numpy.min_scalar() method finds the minimal data type. # The 1st parameter is the value whose minimal data type is to be found. print("Using the min_scalar() method in Numpy\n") print("Result...",np.min_scalar_type(55)) print("Result...",np.min_scalar_type(38.9)) print("Result...",np.min_scalar_type(-78)) print("Result...",np.min_scalar_type(479)) print("Result...",np.min_scalar_type(2e100)) print("Result...",np.min_scalar_type(-45.8)) print("Result...",np.min_scalar_type(6.5e100))
আউটপুট
Using the min_scalar() method in Numpy Result... uint8 Result... float16 Result... int8 Result... uint16 Result... float64 Result... float16 Result... float64