Pandas Index가 부울로만 구성되어 있는지 확인하려면 index.is_boolean()을 사용하세요. Pandas의 메소드. 먼저 필요한 라이브러리를 가져옵니다. -
import pandas as pd
판다 색인 생성
index = pd.Index([True, True, False, False, True, True, True])
판다 인덱스 표시 -
print("Pandas Index...\n",index) 인덱스 값에 부울만 있는지 확인 -
print("\nIndex values only consists of booleans?\n",index.is_boolean())
예시
다음은 코드입니다 -
import pandas as pd
# Creating Pandas index
index = pd.Index([True, True, False, False, True, True, True])
# 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 booleans
print("\nIndex values only consists of booleans?\n",index.is_boolean()) 출력
이것은 다음과 같은 출력을 생성합니다 -
Pandas Index... Index([True, True, False, False, True, True, True], dtype='object') Number of elements in the index... 7 The dtype object... object Index values only consists of booleans? True