1. DataFrame - key와 value를 쌍으로 지녀, key를 통해 value에 접근 가능
예) @데이터 만들기
data = {'city': ['Seoul', 'Busan', 'Daegu', 'Ulsan'], 'year': [2010, 2011, 2012, 2013]} //데이터 생성
frame = pandas.Dataframe(data) //Dataframe 만들기
@원하는 순서대로 열을 지정 가능
frame2 = pandas.Dataframe(data, columns=['year', 'city']) //컬럼명을 year와 city로 지정
@행에도 index(색인)설정 가능
frame3 = pandas.Dataframe(data, index=['one', 'two', 'three', 'four']) //index를 one, two, three, four로 설정
@행, 열 전치 가능
frame3.T //행과 열을 바꿈
@특정 행이나 열 삭제 가능 (drop)
frame3.drop[['two', 'three']] //행 삭제
frame3..drop['eity', axis=1] //열 삭제
@특정 값에 의해 정렬 가능
frame4 = pandas.DataFrame([[1,3,2,5], [4,2,5,1]], index = ['three', 'one'], columns=['d', 'a', 'b', 'c']) //데이터 생성
frame4.sort_index() //index에 의해 정렬
frame4.sort_index(axis=1, ascending=False) //내림차순에 의해 정렬, axis는 아직 잘 이해 못함
frane4.sort_values(by=['c']) //c 컬럼 값에 의한 정렬 (기본 설정 오름차순)
Reference. 잡아라! 텍스트 마이닝 with 파이썬, 서대호 저, 비제이퍼블릭
'개인공부 > Python(Anaconda, NLTK)' 카테고리의 다른 글
Python(PorterStemmer, LancasterStemmer, RegexpStemmer) (0) | 2019.10.14 |
---|---|
Python (re) (0) | 2019.10.14 |
Python(numpy) (0) | 2019.10.11 |
Python (Pandas.Series) (0) | 2019.10.11 |
Install NLTK on Windows(윈도우 NLTK 설치) (0) | 2019.10.10 |