Pandas Index가 부동 유형인지 확인하려면 index.is_floating()을 사용하세요. Pandas의 메소드. 먼저 필요한 라이브러리를 가져옵니다. -
import pandas as pd
판다 인덱스 생성 -
index = pd.Index([5.7, 6.8, 10.5, 20.4, 25.6, 30.8, 40.5, 50.2])
팬더 인덱스 표시 -
print("Pandas Index...\n",index) 인덱스 값에 float만 있는지 확인하십시오 -
print("\nIndex values only consists of floats?\n",index.is_floating()) 예시
다음은 코드입니다 -
import pandas as pd
# Creating Pandas index
index = pd.Index([5.7, 6.8, 10.5, 20.4, 25.6, 30.8, 40.5, 50.2])
# 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 floats
print("\nIndex values only consists of floats?\n",index.is_floating()) 출력
이것은 다음과 같은 출력을 생성합니다 -
Pandas Index... Float64Index([5.7, 6.8, 10.5, 20.4, 25.6, 30.8, 40.5, 50.2], dtype='float64') Number of elements in the index... 8 The dtype object... float64 Index values only consists of floats? True