성동1기 전Z전능 데이터 분석가 과정
[성동1기 전Z전능 데이터 분석가] 46일차 전처리
데이터분석가_안졍
2023. 12. 27. 19:28
728x90
각 column마다 group by를 적용하여 null값 존재 여부 확인
select '각 column명', count(*) from delivery d group by 1 order by 2 desc ;
날짜, 시간이 문자열로 저장된 column들을 date or datetime으로 변환
UPDATE delivery SET ship_date = DATE_FORMAT(ship_date , '%Y-%m-%d'); UPDATE delivery SET ship_time = STR_TO_DATE(ship_time, '%Y-%m-%d %H:%i:%s.%f')
영남1센터' 데이터를 'YC0'로 변환
UPDATE delivery SET center_code = 'YC0' WHERE center_code = '영남1센터'
Null로 되어있는 지역을 'etc'로 변환
UPDATE delivery SET region = 'etc' WHERE region is null
Null로 되어있는 배송지코드를 'etc_code'로 변환
UPDATE delivery SET destination_code = 'etc_code' WHERE destination_code is null
(View를 통해) Analysis 테이블 생성
create view Analysis as
select d.ship_date, d.ship_id, d.ship_id_seq, d.ship_type, d.region, d.qt, d.ship_time, d.box_qt, d.unit_qt, d.center_code, d.dc_tc, d.destination_code, d.product_code, p.condition, p.remark1, p.remark2
from delivery d
left join product p on d.product_code = p.product_code ;