기본 데이터 모양의 튜플을 반환하려면 index.shape를 사용하세요. Pandas의 속성
먼저 필요한 라이브러리를 가져옵니다 -
import pandas as pd
인덱스 생성 -
index = pd.Index(['Car','Bike','Truck','Car','Airplane'])
인덱스 표시 -
print("Pandas Index...\n",index) 기본 데이터 모양의 튜플 반환 -
print("\nA tuple of the shape of underlying data...\n",index.shape)
예
다음은 코드입니다 -
import pandas as pd
# Creating the index
index = pd.Index(['Car','Bike','Truck','Car','Airplane'])
# Display the index
print("Pandas Index...\n",index)
# Return an array representing the data in the Index
print("\nArray...\n",index.values)
# Return a tuple of the shape of the underlying data
print("\nA tuple of the shape of underlying data...\n",index.shape) 출력
이것은 다음 코드를 생성합니다 -
Pandas Index... Index(['Car', 'Bike', 'Truck', 'Car', 'Airplane'], dtype='object') Array... ['Car' 'Bike' 'Truck' 'Car' 'Airplane'] A tuple of the shape of underlying data... (5,)