কম্পিউটার

পাইথন - পান্ডাস ইনডেক্সে শুধুমাত্র সাংখ্যিক ডেটা রয়েছে কিনা তা পরীক্ষা করুন


পান্ডাস সূচকে শুধুমাত্র সাংখ্যিক ডেটা আছে কিনা তা পরীক্ষা করতে, index.is_numeric() ব্যবহার করুন পদ্ধতি প্রথমে, প্রয়োজনীয় লাইব্রেরি আমদানি করুন -

import pandas as pd
import numpy as np

পূর্ণসংখ্যা, ফ্লোট এবং NaNs দিয়ে পান্ডাস সূচক তৈরি করা হচ্ছে

index = pd.Index([5, 10.2, 25, 50, 75.2, 100, np.nan])

পান্ডাস সূচক প্রদর্শন করুন -

print("Pandas Index...\n",index)

সূচক মান শুধুমাত্র সংখ্যাসূচক তথ্য আছে কিনা পরীক্ষা করুন. সংখ্যাসূচক তথ্য পূর্ণসংখ্যা, ভাসমান এবং NaNs −

অন্তর্ভুক্ত করে
index.is_numeric()

উদাহরণ

নিম্নলিখিত কোড -

import pandas as pd
import numpy as np

# Creating Pandas index with integer, float and NaNs
index = pd.Index([5, 10.2, 25, 50, 75.2, 100, np.nan])

# Display the Pandas index
print("Pandas Index...\n",index)

# Return the number of elements in the Index
print("\nNumber of elements in the index...\n",index.size)

# Return the dtype of the data
print("\nThe dtype object...\n",index.dtype)

# Check whether index values has only numeric data.
# Numeric data includes integer, floats and NaNs
print("\nIndex values only consists of numeric data?\n",index.is_numeric())

আউটপুট

এটি নিম্নলিখিত আউটপুট −

তৈরি করবে
Pandas Index...
Float64Index([5.0, 10.2, 25.0, 50.0, 75.2, 100.0, nan], dtype='float64')

Number of elements in the index...
7

The dtype object...
float64

Index values only consists of numeric data?
True

  1. পাইথন - পান্ডাস সূচকে শুধুমাত্র পূর্ণসংখ্যা রয়েছে কিনা তা পরীক্ষা করুন

  2. Python - পান্ডাস সূচক একটি ভাসমান প্রকার কিনা তা পরীক্ষা করুন

  3. পাইথন - পান্ডাস সূচকে সুনির্দিষ্ট ডেটা আছে কিনা তা পরীক্ষা করুন

  4. পাইথন - পান্ডাস সূচকে শুধুমাত্র বুলিয়ান রয়েছে কিনা তা পরীক্ষা করুন