오늘 한 일
- 코드카타
더보기
31. 수박수박수박수?
def solution(n):
if n%2==0:
answer='수박'*(n//2)
elif n%2!=0:
answer='수'+'박수'*round(n//2)
return answer
이제 레벨2다
저번주에 이 문제 도전했을때는 어려워서 접근을 못 했는데 이번에 다시 도전하니까 성공함
처음에 에러 떴는데 n/2 해서 float로 나와서 오류 뜬 것 같아서 n//2로 고쳤더니 성공적으로 돌아감.
근데 다른사람들 풀이 보니까 한두줄로 간결하게 끝낸 사람도 있던.. 난 아직 그정도 레벨은 안되는듯
32.내적
def solution(a, b):
answer = 0
for i in range(len(a)):
answer = answer + a[i]*b[i]
return answer
그냥 인덱스에 숫자를 반복해서 넣기 했더니쉽게 해결됨
- 파이썬 개인과제
더보기
3-3
복붙 메모장
df['Date'] = pd.to_datetime(df['Date'])
df['Month'] = df['Date'].dt.month
result_map = {9999:np.nan}
df['Defects'] = df['Defects'].replace(result_map)
df['DefectRate'] = df['Defects']/df['Production']
#월별 각 라인의 평균 불량률 추이
plt.plot(line_avg['Line'],line_avg['DefectRate'],colors['#5b6777','#f15628','ffc81b'],linestyle='-',marker='o')
plt.xlabel('Month')
plt.ylabel('Defect Rate')
plt.title('Defect Rate Trend Over Time')
plt.grid(True)
plt.legend(ncol=3)
plt.show()
각 라인의 월별 평균 불량률 변화를 알아보기 위해 꺾은선 그래프 제작
# 라이브러리 불러오기
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
# CSV 파일 불러오기
duplicates_path = '/content/manufacturing_data_400.csv' # data_with_duplicates.csv 파일 경로 입력
df = pd.read_csv(duplicates_path) # 파일 경로에 맞게 조정하세요
df['Date'] = pd.to_datetime(df['Date'])
df['Month'] = df['Date'].dt.month
result_map = {9999:np.nan}
df['Defects'] = df['Defects'].replace(result_map)
df['DefectRate'] = df['Defects']/df['Production']
pivot_df = df.pivot_table(index='Month',
columns='Line',
values='DefectRate',
aggfunc='mean')
fig, ax = plt.subplots()
for column in pivot_df.columns:
ax.plot(pivot_df.index, pivot_df[column],marker='o', label=column)
ax.set_xlabel('Month')
ax.set_xticks(pivot_df.index)
ax.legend()
ax.set_ylabel('Defect Rate')
ax.set_title('Defect Rate Over Time')
- 데이터 분석 입문 3회차 세션 - 개인미션
'내일배움캠프(본캠프)' 카테고리의 다른 글
| [내일배움캠프] 본캠프 4/3 (0) | 2026.04.03 |
|---|---|
| [내일배움캠프] 본캠프 4/2 (0) | 2026.04.02 |
| [내일배움캠프] 본캠프 3/31 (0) | 2026.03.31 |
| [내일배움캠프] 본캠프 3/30 (0) | 2026.03.30 |
| [내일배움캠프] 본캠프 3/27 (0) | 2026.03.27 |