일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 준연동형비례대표
- 40대아빠육아
- 파리브레스트파리
- 국민을 위한 국민연금은 없다
- 인공지능
- 남자육아휴직
- 아빠육아
- 감나무전지
- 대한민국선거
- 콜로라도
- 샤오미
- 도로패임
- 전동전기톱
- 데이터시각화
- 가칭 동남고등학교
- 저출산
- MTB
- 미지아
- 액티언스포츠
- 자전거
- 오프로드
- 육아휴직급여
- 픽업트럭
- 싸이클
- 2024년 합계출산율
- 청주시 일반계 고등학교
- 엔진오일
- 청주시 지하철
- 코란도스포츠
- 중고노트북
Archives
- Today
- Total
열심히 일한 당신 떠나라
2024년 2월 강수량 본문
2024년 2월은 비가 참 많이 왔습니다. 청주 지역은 중부 지방임에도 불구하고 눈은 거의 오지 않고 비만 계속 왔습니다. 2월 25일까지 얼마나 비가 내렸는지 확인해 볼까요?
import pandas as pd
# 강수량 데이터를 불러옵니다.
data_path_precipitation = '/content/drive/MyDrive/데이터분석/cj_precipitation.csv'
# pandas를 사용하여 데이터를 로드합니다.
df_precipitation = pd.read_csv(data_path_precipitation, encoding='CP949')
# 데이터가 잘 로드되었는지 확인합니다.
df_precipitation.head(), df_precipitation.tail()
앞서 작성한 블로그에서 기상청 데이터 다운로드 방법은 확인할 수 있습니다.
https://ax7taehun.tistory.com/138
우선 다른 해에도 비가 이렇게 많이 온 적이 있을까?
# 데이터를 datetime 객체로 변환합니다.
df_precipitation['date'] = pd.to_datetime(df_precipitation['date'])
# 강수량 데이터가 NaN인 경우를 0으로 처리합니다.
df_precipitation['precipitation'].fillna(0, inplace=True)
# 2월의 연도별 강수량 데이터를 준비합니다.
feb_precipitation_by_year = df_precipitation\
[df_precipitation['date'].dt.month == 2].\
groupby(df_precipitation['date'].dt.year)['precipitation'].sum()
# 2024년 2월 강수량과 비교할 수 있는 수치인지 확인합니다.
precipitation_feb_2024 = feb_precipitation_by_year[2024]
print(f'2월에 가장 비가 많이 온 연도는 {feb_precipitation_by_year.idxmax()}년입니다.\n\
그 해 강수량은 {feb_precipitation_by_year.max()}mm이고,\n\
2024년 2월 강수량은 {precipitation_feb_2024}mm입니다.')
2월에 가장 비가 많이 온 연도는 1990년입니다. 그 해 강수량은 99.2mm이고, 2024년 2월 강수량은 79.0mm입니다.
코드를 실행해 보니 1990년 2월에 비가 참 많이 왔네요. 기상청 자료를 확인한 결과 평년 강수량이 27.5~44.9㎜정도니까 2024년 2월이 엄청 많이 내린 것은 맞습니다. 1990년에도 99.2mm가 왔으니 2024년보다 많이 온 게 확인이 되네요.
import matplotlib.pyplot as plt
# 데이터를 datetime 객체로 변환합니다.
df_precipitation['date'] = pd.to_datetime(df_precipitation['date'])
# 강수량 데이터가 NaN인 경우를 0으로 처리합니다.
df_precipitation['precipitation'].fillna(0, inplace=True)
# 2월의 연도별 강수량 데이터를 준비합니다.
feb_precipitation_by_year = df_precipitation[df_precipitation['date'].dt.month == 2].groupby(df_precipitation['date'].dt.year)['precipitation'].sum()
# 2월 강수량 시각화
plt.figure(figsize=(14, 7))
feb_precipitation_by_year.plot(kind='bar', color='skyblue', edgecolor='black')
plt.title('February Precipitation by Year')
plt.xlabel('Year')
plt.ylabel('Precipitation (mm)')
plt.grid(True, linestyle='--', alpha=0.7)
plt.show()
비가 온 날을 세어보겠습니다.
# 비가 온 날을 카운트합니다. 여기서는 강수량이 0보다 큰 날을 비가 온 날로 가정합니다.
rainy_days_by_year = df_precipitation[df_precipitation['precipitation'] > 0].groupby(df_precipitation['date'].dt.year).size()
# 2월에 해당하는 데이터만 필터링합니다.
rainy_days_feb_by_year = df_precipitation[(df_precipitation['precipitation'] > 0) & (df_precipitation['date'].dt.month == 2)].groupby(df_precipitation['date'].dt.year).size()
# 2월의 비가 온 날짜 카운트 시각화
plt.figure(figsize=(14, 7))
rainy_days_feb_by_year.plot(kind='bar', color='lightblue', edgecolor='black')
plt.title('Number of Rainy Days in February by Year')
plt.xlabel('Year')
plt.ylabel('Number of Rainy Days')
plt.grid(True, linestyle='--', alpha=0.7)
plt.show()
비 온 날을 세보니 역대급으로 비가 많이 온 건 확인할 수 있네요. 25중에 12일이 비가 왔으니 말이죠.
'일상생활' 카테고리의 다른 글
육아휴직 급여 입금 (1) | 2024.03.15 |
---|---|
올해 유독 포트홀이 많은 이유(윈터타이어) (0) | 2024.03.08 |
고등학교 입학 시 학부모 할 일 (1) | 2024.02.18 |
6개월 유아와 대한항공 탑승 (0) | 2023.03.02 |
아이 이름 영어로 변환 (0) | 2023.03.02 |