Hi there!

I am a student studying computer science.

AI/Pandas 기초

05. 데이터프레임 행, 열 삭제하기

만능성구 2020. 4. 24. 19:22
728x90

-drop

df.drop(['John', 'Nate'])

df.drop(['John', 'Nate'], inplace = True)

'John', 'Nate' 는 행의 index이다.

행 삭제

적용되지는 않는다.

inplace 를 해주면 바로 적용된다.

 

df.drop(df.index[[0,2]])

index로 접근하여 

행삭제

 

df[df.age>20]

조건에 따라서

행삭제

 

df = df.drop('age', axis =1)

column 이름으로

열삭제

728x90