관리 메뉴

RUBY

[CCTV] 3.Pandas로 데이터 읽기(4) 본문

데이터 분석/EDA_웹크롤링_파이썬프로그래밍

[CCTV] 3.Pandas로 데이터 읽기(4)

ruby-jieun 2023. 2. 1. 00:54

 

 

 

서울시 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)
Comments