সূচকটি 0টি উপাদান সহ খালি কিনা তা পরীক্ষা করতে, index.empty ব্যবহার করুন পান্ডাসে সম্পত্তি।
প্রথমে, প্রয়োজনীয় লাইব্রেরিগুলি আমদানি করুন -
import pandas as pd
সূচক তৈরি করা হচ্ছে -
index = pd.Index([])
সূচক প্রদর্শন করুন -
print("Pandas Index...\n",index) খালি সূচী পরীক্ষা করুন -
print("\nIs the index empty?\n",index.empty)
উদাহরণ
নিম্নলিখিত কোড -
import pandas as pd
# Creating the index
index = pd.Index([])
# Display the index
print("Pandas Index...\n",index)
# Return the number of elements in the Index
print("\nNumber of elements in the index...\n",index.size)
# check for empty index
print("\nIs the index empty?\n",index.empty) আউটপুট
এটি নিম্নলিখিত কোড তৈরি করবে -
Pandas Index... Index([], dtype='object') Number of elements in the index... 0 Is the index empty? True