일부 NaN이 있는 Pandas 인덱스가 부동 유형인지 확인하려면 index.is_floating()을 사용하세요. 방법. 먼저 필요한 라이브러리를 가져옵니다 -
import pandas as pd import numpy as np
일부 NaN을 사용하여 Pandas 인덱스 만들기 −
index = pd.Index([5.7, 6.8, 10.5, np.nan,17.8, 25.6, np.nan ,np.nan, 50.2])
판다 인덱스 표시 -
print("Pandas Index...\n",index) 일부 NaN이 있는 인덱스 값이 부동 유형인지 확인 -
print("\nIndex values with some NaNs is a floating type?\n",index.is_floating()) 예시
다음은 코드입니다 -
import pandas as pd
import numpy as np
# Creating Pandas index with some NaNs
index = pd.Index([5.7, 6.8, 10.5, np.nan,17.8, 25.6, np.nan ,np.nan, 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 with some NaNs are floating type
print("\nIndex values with some NaNs is a floating type?\n",index.is_floating()) 출력
이것은 다음과 같은 출력을 생성합니다 -
Pandas Index... Float64Index([5.7, 6.8, 10.5, nan, 17.8, 25.6, nan, nan, 50.2], dtype='float64') Number of elements in the index... 9 The dtype object... float64 Index values with some NaNs is a floating type? True