잠토의 잠망경

[Pandas] 데이터 추출(행, Row)-iloc 본문

공부/Python

[Pandas] 데이터 추출(행, Row)-iloc

잠수함토끼 2018. 12. 23. 11:38

iloc 속성 활용

Data 순서를 의미하는 번호를 활용

-1 은 마지막 행을 의미한다.

존재하지 않는 번호는 오류 발생함

loc DataFrame의 Index를 활용함

df.iloc[1]
df.iloc[99]
df.iloc[-1] #미지막 행 데이터를 추출
print(type(df.iloc[-1])) #Series

여러행 추출하기

list의 형태를 통하여 얻을 수 있음

print(df.iloc[[0,0,99]]) # list를 넘겨준다.
Comments