Daily plan
๐์ค์
- SQL ์ฝ๋์นดํ 89, 90, 91
- 10์ ํต๊ณ ๋ผ์ด๋ธ์ธ์
- 11์ 30๋ถ ๋ฐ์ ?
๐ฅ ์คํ
- ํต๊ณ ๋ผ์ด๋ธ์ธ์
์ ๋ฆฌ
- ์คํ ๋ค๋ 4ํ์ฐจ ์ค์ต ๋ณต์ต
- ํต๊ณ ๊ฐ์ 2์ฃผ์ฐจ + 3์ฃผ์ฐจ~~
๐ ์ ๋
- ํ์ด์ฌ ๊ฐ์ธ๊ณผ์ ํผ๋๋ฐฑ ํ์ธ
- ๋ฐ์ดํฐ ์ ์ฒ๋ฆฌ&์๊ฐํ 3์ฃผ์ฐจ ๋ค์ ๋ณต์ต
To Do
์ด๋ฒ์ฃผ ๋ชฉํ
select machine_id,
round(avg(time_diff),3) as processing_time
from(
select a1.machine_id, a1.process_id,
a2.timestamp-a1.timestamp as time_diff
from activity a1
join activity a2
on a1.machine_id=a2.machine_id
and a1.process_id=a2.process_id
and a1.activity_type = 'start'
and a2.activity_type = 'end'
) t
group by machine_id
select e.name, b.bonus
from employee e
left join bonus b
on e.empId = b.empId
where b.bonus<1000 or b.bonus is null
๋ฌธ์ ์กฐ๊ฑด์์ null๊ฐ์ ๊ฐ๋ ๊ฒฝ์ฐ๋ ์ถ๋ ฅํ๋ผ๊ณ ํด์
select st.student_id, st.student_name, sub.subject_name,
if(e.cnt is null, 0, e.cnt) attended_exams
from students st
cross join subjects sub
left join (select student_id, subject_name, count(1) cnt
from examinations
group by student_id, subject_name) e
on st.student_id = e.student_id
and sub.subject_name=e.subject_name
order by student_id, subject_name
๋ ์ข์ ์ฟผ๋ฆฌ๊ฐ ์๋์ง ์งํผํฐ ์ ์๋๊ป ์ฌ์ญค๋ณธ ๊ฒฐ๊ณผ
WITH exam_counts AS (
SELECT
student_id,
subject_name,
COUNT(*) AS cnt
FROM examinations
GROUP BY student_id, subject_name
)
SELECT
st.student_id,
st.student_name,
sub.subject_name,
COALESCE(e.cnt, 0) AS attended_exams
FROM students st
CROSS JOIN subjects sub
LEFT JOIN exam_counts e
ON st.student_id = e.student_id
AND sub.subject_name = e.subject_name
ORDER BY st.student_id, sub.subject_name;
SELECT a, b, COALESCE(a,b) FROM test;
ํ์ด์ฌ ์ค์ต
# ์ ๊ท๋ถํฌ ์์ฑ normal_dist = np.random.normal(170, 10, 1000) # ํ๊ท , ํ์คํธ์ฐจ, ๊ฐ์ # # ํ์คํ ๊ทธ๋จ ์๊ฐํ plt.hist(normal_dist, bins=30, density=True, alpha=0.6, color='g') # # ์ ๊ท๋ถํฌ ๊ณก์ ์ถ๊ฐ xmin, xmax = plt.xlim() x = np.linspace(xmin, xmax, 100) p = stats.norm.pdf(x, 170, 10) plt.plot(x, p, 'k', linewidth=2) plt.title('normal distribution histogram') plt.show() # # ์ ๊ท๋ถํฌ ๊ณก์ ์ ์ถ๊ฐํ์ฌ ํ์คํ ๊ทธ๋จ์ด ์ ๊ท๋ถํฌ์ ์ผ๋ง๋ ๊ฐ๊น์ด ํํ๋ฅผ ๋๋์ง ํ์ธํ ์ ์์
ํ์ด์ฌ ์ค์ต
# ๊ธด ๊ผฌ๋ฆฌ ๋ถํฌ ์์ฑ long_tail = np.random.exponential(1,1000) # # ํ์คํ ๊ทธ๋จ ์๊ฐํ plt.hist(long_tail, bins=30, density=True, alpha=0.6, color='b') plt.title('long tail distribution histogram') plt.show()
ํ์ด์ฌ ์ค์ต
# ์คํ๋ํธ t๋ถํฌ ์์ฑ t_dist = np.random.standard_t(df=10, size=1000) # df๋ ์์ ๋๋ฅผ ์๋ฏธ # # ํ์คํ ๊ทธ๋จ ์๊ฐํ plt.hist(t_dist, bins=30, density=True, alpha=0.6, color='r' # # ์คํ๋ํธ t๋ถํฌ ๊ณก์ ์ถ๊ฐ x = np.linspace(-4,4,100) p = stats.t.pdf(x, df=10) plt.plot(x, p, 'k', linewidth=2) plt.title('student t distribution histogram') plt.show()
ํ์ด์ฌ ์ค์ต
# ์นด์ด์ ๊ณฑ๋ถํฌ ์์ฑ chi2_dist = np.random.chisquare(df=2, size=1000) # # ํ์คํ ๊ทธ๋จ์ผ๋ก ์๊ฐํ plt.hist(chi2_dist, bins=30, density=True, alpha=0.6, color='m') # # ์นด์ด์ ๊ณฑ๋ถํฌ ๊ณก์ ์ถ๊ฐ x = np.linspace(0,10,100) p = stats.chi2.pdf(x, df=2) plt.plot(x, p, 'k', linewidth=2) plt.title('์นด์ด์ ๊ณฑ ๋ถํฌ ํ์คํ ๊ทธ๋จ') plt.show()
ํ์ด์ฌ ์ค์ต
# ์ดํญ๋ถํฌ ์์ฑ binom_dist = np.random.binomial(n=10, p=0.5, size=1000) # # ํ์คํ ๊ทธ๋จ ์๊ฐํ plt.hist(binom_dist, bins=10, density=True, alpha=0.6, color='y') plt.title('์ดํญ ๋ถํฌ ํ์คํ ๊ทธ๋จ') plt.show()
ํ์ด์ฌ ์ค์ต
import numpy as np import matplotlib.pyplot as plt from scipy.stats import poisson # # ํธ์์ก ๋ถํฌ ํ๋ผ๋ฏธํฐ ์ค์ lambda_value = 4 ## ํ๊ท ๋ฐ์๋ฅ x = np.arange(0,15) ## ์ฌ๊ฑด ๋ฐ์ ํ์ ๋ฒ์ # # ํธ์์ก ๋ถํฌ ํ๋ฅ ์ง๋ ํจ์ ๊ณ์ฐ poisson_pmf = poisson.pmf(x, lambda_value) # # ๊ทธ๋ํ ๊ทธ๋ฆฌ๊ธฐ plt.figure(figsize=(10,6)) plt.bar(x, poisson_pmf, alpha=0.6, color='b', label=f'Poisson PMF (lambda={lambda_value})') plt.xlabel('Number of Events') plt.ylabel('Probability') plt.title('Poisson Distribution') plt.legend() plt.grid(True) plt.show()
3์ฃผ์ฐจ ๋ด์ฉ์ ์ค๋ ํต๊ณ ๋ผ์ด๋ธ์ธ์ ์ผ๋ก ๋ค์ ๋ด์ฉ์ด๋ ๋๋ฌด ๊ฒน์ณ์ ๋ณต์ตํ ๊ฒธ ๋ด์ผ ๋ค์ด์ผ๊ฒ ๋ค
์ขํ ์ค์ ์ค๋ฅ.. y์ขํ ๊ณ์ฐํด์ผ ํ๋ ์๋ฆฌ์ x์ขํ ๊ณ์ฐํจ
- i[1][j+1][1]-i[1][j][0] -> i[1][j+1][1]-i[1][j][1] ์ผ๋ก ์์
def calculate_total_distances(player_positions): # ์ฌ๊ธฐ์ ์ฝ๋๋ฅผ ์์ฑํ์ธ์ for i in player_positions.items(): distance=0 for j in range(len(i[1])-1): distance += ((i[1][j+1][0]-i[1][j][0])**2+(i[1][j+1][1]-i[1][j][1])**2)**(1/2) print (i[0]+"์ ์ด ๋์ ์ด๋ ๊ฑฐ๋ฆฌ: "+str(round(distance,2))+" ๋ฏธํฐ")
ํํฐ๋ ํผ๋๋ฐฑ์ด ์ดํด๊ฐ ๊ฐ์ง ์์์...
"์ํธ ํด๋ ํจ์๊ฐ ์์ด์ ํ๊ธ ์ซ์๋ฅผ ์ฒ๋ฆฌํ๋ ๊ธฐ๋ณธ ๋ก์ง์ ๊ฐ์ถ๊ณ ์์ต๋๋ค. ๋ค๋ง ์์ด ์ซ์ ์ฒ๋ฆฌ ๋ถ๋ถ์์ ๋ฌธ์์ด ์์ ๋ ๊ธ์๋ง ํ์ธํ๋ ๋ฐฉ์์ ์ ์ฒด ๋จ์ด๋ฅผ ์ฌ๋ฐ๋ฅด๊ฒ ํ๋ณํ์ง ๋ชปํ ์ ์์ต๋๋ค. ์๋ฅผ ๋ค์ด "five"์ "four"๋ ์ฒซ ๋ ๊ธ์๊ฐ ๊ฐ์ต๋๋ค." (?????)
์ด๊ฑด ๋ด์ผ ํํฐ๋๊ป ์ง๋ฌธํ๋ฌ ๊ฐ์ผ๊ฒ ๋ค..

ํ๋ณต์ ๋ง์ท์ด์
ํผ๋ถ์๋ ์ฐธ ์๋์ค๋ฝ๋ค

5์กฐ์ ์ ์๊ตฌ๊ฐ ์๊ฒผ์ด์
๊ท์ฌ์ด ๋น์
์ด๋ฆ: ๋น์์ธ๋์ฉ (๋น์์ธ...'๋์ฉ'....)
๋ณธ๊ฐ์ ์์ ํ๋ฃจ์ข
์ผ ๋จน๊ธฐ๋งํ๋๋ ์ผ๊ตด์ด ๋๋ฌด ๋ถ์ ๊ฑฐ ๊ฐ๋คใ
๋ถ๋ช
์ด์ ์ง์ ๋์ฐฉํ์ ๋๋ง ํด๋ ๋ฐฐ๊ฐ ์ข ํ์ญํ๋๋ฐ ์ง๊ธ์ ๋นต๋นตํด์ง..
์ด์ฐ๊ธฐ ์ ์ ์ด์ ์์ธ๋ก ๋์๊ฐ์ผ๊ฒ ๋ค,,