Pandas drop()

1 개요[ | ]

Pandas drop()
판다스 drop()
import pandas as pd
df = pd.DataFrame([
[5.1, 1.4, "setosa"],
[4.9, 1.4, "setosa"],
[4.7, 1.3, "setosa"],
],columns=['Sepal.Length', 'Petal.Length', 'Species'])
print( df )
행 삭제
import pandas as pd
df = pd.DataFrame([
[5.1, 1.4, "setosa"],
[4.9, 1.4, "setosa"],
[4.7, 1.3, "setosa"],
],columns=['Sepal.Length', 'Petal.Length', 'Species'])
print( df.drop(1) )
import pandas as pd
df = pd.DataFrame([
[5.1, 1.4, "setosa"],
[4.9, 1.4, "setosa"],
[4.7, 1.3, "setosa"],
],columns=['Sepal.Length', 'Petal.Length', 'Species'])
print( df.drop([0,1]) )
열 삭제
import pandas as pd
df = pd.DataFrame([
[5.1, 1.4, "setosa"],
[4.9, 1.4, "setosa"],
[4.7, 1.3, "setosa"],
],columns=['Sepal.Length', 'Petal.Length', 'Species'])
print( df.drop(columns=['Sepal.Length', 'Petal.Length']) )
import pandas as pd
df = pd.DataFrame([
[5.1, 1.4, "setosa"],
[4.9, 1.4, "setosa"],
[4.7, 1.3, "setosa"],
],columns=['Sepal.Length', 'Petal.Length', 'Species'])
print( df.drop(['Sepal.Length', 'Petal.Length'], axis=1) )

2 같이 보기[ | ]

3 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}