본문 바로가기
2/[ Python ]

How do I remove columns from a pandas DataFrame?

by Kieran_Han 2020. 11. 26.

Source: youtu.be/gnUKkS964WQ

ufo = pd.read_csv('http://bit.ly/uforeports')

ufo.head()

#(row, column) 조회

ufo.shape

#axis = 0 -> row axis, axis = 1 -> column axis

ufo.drop('Colors Reported', axis=1, inplace=True)

ufo.head()

#2개 이상 제거할 경우 [] 이용

ufo.drop(['City', 'State'], axis = 1, inplace=Ture)

ufo.head()

#row 제거하는 법

ufo.drop([0, 1], axis=0, inplace=Ture)

ufo.head()

#row 제거 확인 완료

ufo.shape