Pandas Index에서 NA가 아닌 항목을 표시하려면 index.notna()를 사용하세요. 방법. 먼저 필요한 라이브러리를 가져옵니다. -
import pandas as pd import numpy as np
일부 NaN 값으로 Pandas 인덱스 생성 -
index = pd.Index([5, 65, np.nan, 17, 75, np.nan])
판다 인덱스 표시 -
print("Pandas Index...\n",index) Pandas 인덱스에서 NA가 아닌 항목을 표시합니다. NA가 아닌 항목에 대해 True 반환 -
print("\nCheck which entries are not-NA...\n", index.notna())
예시
다음은 코드입니다 -
import pandas as pd
import numpy as np
# Creating Pandas index with some NaN values
index = pd.Index([5, 65, np.nan, 17, 75, 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)
# Show which entries in a Pandas index are not-NA
# Return True for non-NA entries
print("\nCheck which entries are not-NA...\n", index.notna()) 출력
이것은 다음과 같은 출력을 생성합니다 -
Pandas Index... Float64Index([5.0, 65.0, nan, 17.0, 75.0, nan], dtype='float64') Number of elements in the index... 6 The dtype object... float64 Check which entries are not-NA... [ True True False True True False]