"Pandas 데이터프레임 인덱스로 컬럼 제거"의 두 판 사이의 차이

23번째 줄: 23번째 줄:


==같이 보기==
==같이 보기==
* [[Pandas .drop()]]
* [[Pandas 데이터프레임 컬럼 제거]]
* [[Pandas 데이터프레임 컬럼 제거]]
* [[Pandas 데이터프레임 컬럼명으로 컬럼 제거]]
* [[Pandas 데이터프레임 컬럼명으로 컬럼 제거]]

2021년 3월 14일 (일) 16:15 판

1 개요

Pandas 데이터프레임 인덱스로 컬럼 제거
  • 인덱스는 0부터 시작한다.
import pandas as pd
df = pd.read_csv("https://raw.githubusercontent.com/mwaskom/seaborn-data/master/iris.csv")
print( df.head() )
not-inplace
import pandas as pd
df = pd.read_csv("https://raw.githubusercontent.com/mwaskom/seaborn-data/master/iris.csv")
df2 = df.drop(df.columns[[0,2]], 1)
print( df2.head() )
inplace
import pandas as pd
df = pd.read_csv("https://raw.githubusercontent.com/mwaskom/seaborn-data/master/iris.csv")
df.drop(df.columns[[0,2]], 1, inplace=True)
print( df.head() )

2 같이 보기

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