전체 글(55)
-
[LeetCode] 1965. Employees With Missing Information
SELECT employee_id FROM (SELECT e.employee_id FROM employees AS e LEFT JOIN salaries AS s ON e.employee_id = s.employee_id WHERE s.salary IS NULL UNION SELECT s.employee_id FROM employees AS e RIGHT JOIN salaries AS s ON e.employee_id = s.employee_id WHERE e.name IS NULL)sub ORDER BY 1 OUTER JOIN : FULL OUTER JOIN , LEFT OUTER JOIN, RIGHT OUTER JOIN FULL OUTER JOIN = LEFT JOIN UNION RIGHT JOIN U..
2022.06.16 -
[빅분기] 더미 변수 생성
X1 = data[['gender','region']] X1['gender'] = X1['gender'].replace([1,2],['male','female']) X1['region'] = X1['region'].replace([1,2,3,4,5],['Sudo','Chungcheung','Honam','Youngnam','Others']) X1_dum = pd.get_dummies(X1) Fvote = pd.concat([X1_dum, XY], axis=1 )
2022.06.15 -
[빅분기] 머신러닝
1. 데이터 검토 pandas 라이브러리 임포트 import pandas as pd 파일 불러오기 data = pd.read_csv('breast-cancer-wisconsin.csv') 데이터 확인 : y값의 범주형 여부 확인 ,이상치 여부 확인 data.info() data.head() print(data.shape) data.describe data.hist(bins=50, figsize=(20,15)) 2. x, y 나누기 X = data[data.columns[0:5]] y = data[['house_value']] print(X.shape) print(y.shape) 3. train-test 데이터 셋 나누기 라이브러리 임포트 from sklearn.model_selection import t..
2022.06.13 -
[LeetCode] 626. Exchange Seats
SELECT new_id AS id ,student FROM (SELECT CASE WHEN MOD(id,2)=1 AND id=(SELECT MAX(id) FROM seat) THEN id WHEN MOD(id,2)=1 THEN (id+1) WHEN MOD(id,2)=0 THEN (id-1) END AS new_id, student FROM seat) AS sub ORDER BY new_id;
2022.06.09 -
[LeetCode] 180. Consecutive Numbers
SELECT id AS ConsecutiveNums FROM ( SELECT id, num, LEAD(num,1) OVER (ORDER BY id) AS two_num, LEAD(num,2) OVER (ORDER BY id) AS three_num FROM Logs) sub WHERE num=two_num AND two_num=three_num
2022.06.09 -
[LeetCode] 1050. Actors and Directors Who Cooperated At Least Three Times
SELECT actor_id, director_id FROM ActorDirector GROUP BY 1, 2 HAVING count(*)>=3 GROUP BY 1, 2로 설정 이 경우 COUNT(*)에 그룹 1,2별로 카운트 됨
2022.06.09