RUBY
[CCTV] 3.Pandas로 데이터 읽기(4) 본문
서울시 CCTV 분석하기 프로젝트
3.Pandas로 데이터 읽기(4)
(인구현황 데이터 훑어보기)
1. 서울시 인구 데이터 확인
pop_Seoul.head()
2. 첫 행(0번)의 소계 데이터는 필요없다.
행을 지우는 명령 → drop
pop_Seoul.drop([0], inplace=True)
pop_Seoul.head()
3. unique 조사
pop_Seoul["구별"].unique()
len(pop_Seoul["구별"].unique())
4. 외국과 고령자 비율을 만들어준다.
데이터가 행이 25개인데, 딱 한줄로 의도하는 바를 이룬다.
컬럼 연산이 편하다는 것이 Python의 장점
pop_Seoul["외국인비율"]=pop_Seoul["외국인"]/pop_Seoul["합계"]*100
pop_Seoul["고령자비율"]=pop_Seoul["고령자"]/pop_Seoul["합계"]*100
pop_Seoul.head()
5. 인구수가 많은 구는?
pop_Seoul.sort_values(by="합계", ascending=False).head(5)
6. 외국인이 많은 구는?
pop_Seoul.sort_values(by="외국인", ascending=False).head(5)
7. 외국인 비율이 높은 구는?
pop_Seoul.sort_values(by="외국인비율", ascending=False).head(5)
8. 고령자가 많은 구는?
pop_Seoul.sort_values(by="고령자", ascending=False).head(5)
9. 고령자 비율이 높은 구는?
pop_Seoul.sort_values(by="고령자비율", ascending=False).head(5)
'데이터 분석 > EDA_웹크롤링_파이썬프로그래밍' 카테고리의 다른 글
[CCTV] 5.matplotlib기초 (0) | 2023.02.02 |
---|---|
[CCTV] 4.Pandas 데이터 merge를 이용해서 병합하기 (0) | 2023.02.01 |
[CCTV] 3.Pandas로 데이터 읽기(3) (0) | 2023.02.01 |
[CCTV] 3.Pandas로 데이터 읽기(2) (1) | 2023.02.01 |
[CCTV] 3.Pandas로 데이터 읽기(1) (2) | 2023.01.31 |
Comments