210204 Plotly + Pandas Practice
1 | import pandas as pd |
Table에서 Column 특정 Column 제거하기
제거할 Column은 drop()을 사용해서 제거해준다.
1
2
3
4
5# 제거할 column명을 column 속성을 명시해서 제거하거나
df = df.drop(column=["Column1","Column2","Column3","Column4"]).sum().reset_index(name="total")
# 명시하지 않고 axis=1를 추가해서 제거할 수 있다.
df = df.drop(["Column1","Column2","Column3","Column4"], axis=1).sum().reset_index(name="total")
# 제거된 column을 제외한 column을 기준으로 합계(sum)를 구하고 series를 data frame으로 바꿔준다. 바꾼 후에 새로 추가된 합계 column의 이름은 "total"로 지정해준다. (.reset_index("total"))