Get the Size of a DataFrame (#02)

nooooy·2025년 1월 27일

IntroToPandas

목록 보기
2/9

01.27. LeetCode

import pandas as pd

def getDataframeSize(players: pd.DataFrame) -> List[int]:

    return [len(players), len(players.columns)]

DataFrame 사이즈 (행/열)

df.shape
(행, 열)로 출력되며 데이터타입은 tuple.
* tuple: list랑 유사하지만, 값 변경이 불가능한 자료형이다(immutable type). string도 immutable type임.
값이 한 개 일 때는 콤마를 꼭 붙여주어야 한다. 안 붙이면 int로 취급됨. (123,)

DataFrame 행/열 개수

df.shape[0]df.shape[1]
len(df)len(df.columns)

0개의 댓글