https://jimmy-ai.tistory.com/220
[Pandas] 파이썬 피벗테이블 생성 : pd.pivot_table 함수 사용법 정리
파이썬 판다스 pivot_table 함수 사용 예제 파이썬 pandas 모듈의 pd.pivot_table 함수로 피벗테이블을 원하는대로 생성하는 방법을 values, index, columns, fill_value 및 aggfunc 인자의 기능을 위주로 정리해..
jimmy-ai.tistory.com
table1 = pd.pivot_table(df, values='국어', index=['반'], columns=['전공'], aggfunc=np.mean)
table1
pd.pivot과 pd.pivot_table의 차이 설명.
pd.pivot_table이 더 사용하기 편하다. pd.pivot은 데이터가 중복되면 에러가 뜬다.
https://kimdingko-world.tistory.com/214
[pandas] 피벗테이블(pivot, pivot_table, unstack)
피벗 테이블이란?¶ 피벗(Pivot) 테이블이란 많은 양의 데이터에서 필요한 자료만을 뽑아 새롭게 표를 작성해 주는 기능입니다. 피벗 테이블을 사용하면 사용자 임의대로 데이터를 정렬하고 필터
kimdingko-world.tistory.com
※ aggfunc를 sum으로 쓰면 따옴표를 안써도되는데, unique한 개수를 세는 count에는 따옴표를 써줘야된다.
※ index랑 values랑 같은 column명을 사용하면 에러나옴. 엑셀은 되는데..
'파이썬. 데이터분석 > Pandas' 카테고리의 다른 글
Pandas : pivot 다중 aggfunc (sum,count 같이) (0) | 2022.09.28 |
---|---|
데이터프레임 어긋나게 나오는것(?)의 이해 (0) | 2022.09.27 |
Pandas DataFrame : agg, as_index (0) | 2022.07.30 |
Pandas DataFrame : query, assign, groupby, agg (0) | 2022.07.26 |
Pandas DataFrame : pivot aggfunc 옵션정리 (0) | 2022.07.25 |