색인 배열, 또는 삭제하려는 로우나 컬럼이 제외된 리스트를 이미 가지고 있다면 로우나 컬럼을
쉽게 삭제할 수 있는데 이 방법은 데이터의 모양을 변경하는 작업이 필요하다.
drop
메서드를
사용하면 선택한 값들이 삭제된 새로운 객체를 얻을 수 있다.
In
[
105
]:
obj
=
pd
.
Series
(
np
.
arange
(
5
.),
index
=
['
a
',
'
b
',
'
c
',
'
d
',
'
e
'])
In
[
106
]:
obj
Out
[
106
]:
a 0
.
0
b 1
.
0
c 2
.
0
d 3
.
0
e 4
.
0
dtype
:
float64
In
[
107
]:
new
_
obj
=
obj
.
drop
('
c
')
In
[
108
]:
new
_
obj
Out
[
108
]:
a 0
.
0
b 1
.
0
d 3
.
0
e 4
.
0
dtype
:
float64
In
[
109
]:
obj
.
drop
(['
d
',
'
c
'])
Out
[
109
]:
a 0
.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.