Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 피그마인디언
- 신경쓰기의 기술
- HackerRank
- Labor Management System
- Inventory Optimization
- 코딩테스트
- MS SQL Server
- MySQL
- 데이터분석
- 코딩테스트연습
- ABC Analysis
- 웨어하우스 보관 최적화
- SKU Consolidation
- 프로그래머스
- Product Demand
- oracle
- 딥러닝
- forecast
- ModelCheckPoint
- tensorflow
- 당신의 인생이 왜 힘들지 않아야 한다고 생각하십니까
- TensorFlowGPU
- eda
- SQL
- pandas profiling
- kaggle
- Gaimification
- ProfileReport
- 파이썬
- leetcode
Archives
- Today
- Total
오늘도 배운다
Forecasts for Product Demand (1) EDA 레포트 생성, 데이터 변환/추가 본문
빅데이터(파이썬)/DA_Forecasts for Product Demand
Forecasts for Product Demand (1) EDA 레포트 생성, 데이터 변환/추가
LearnerToRunner 2022. 12. 27. 20:45Forecasts for Product Demand
데이터셋 구성을 확인하기 위한 EDA 레포트 생성 및 데이터 변환/추가
데이터 타입 확인하기
import pandas as pd
df = pd.read_csv('./archive/Historical Product Demand.csv')
print(df.dtypes)
print(df.columns)
pandas_profiling을 이용해서 레포트 생성하기
import pandas as pd
from pandas_profiling import ProfileReport
df = pd.read_csv('./archive/Historical Product Demand.csv')
profile = ProfileReport(df= df, explorative=True)
profile.to_file('pd_profile.html')
OVERVIEW
PRODUCT_CODE
WAREHOUSE
PRODCT_CATEGORY
DATE
ORDER_DEMAND
데이터 타입 변환하기
Product_Code (str)
>> 'Product_' 삭제 후 int로 전환
Warehouse (str)
>> 'Whse_' 삭제
Product_Category (str)
>> 'Category_' 삭제 후 int로 전환
Date (str)
>> datetime 타입으로 변환 (read_csv에서 처리)
Order_Demand (str)
>> 음수를 표시하는 ()를 제거 후 -(negative)로 전환
>> int 타입으로 변환
# 데이터를 불러올 때 날짜 칼럼을 date형태로 변환
df = pd.read_csv('./archive/Historical Product Demand.csv', parse_dates=['Date'])
"""
Data Conversion
"""
# Product_Code
df['Product_Code'] = df['Product_Code'].str.replace('Product_', '').astype(int)
# Warehouse
df['Warehouse'] = df['Warehouse'].str.replace('Whse_', '')
# Product_Category
df['Product_Category'] = df['Product_Category'].str.replace('Category_', '').astype(int)
# Order Demand
df['Order_Demand'] = df['Order_Demand'].replace('[)]', '', regex=True)
df['Order_Demand'] = df['Order_Demand'].replace('[(]', '-', regex=True)
df['Order_Demand'] = df['Order_Demand'].astype(int)
시계열 데이터 분석을 용이하게 하기 위해 연, 월, 주, 요일 데이터를 추가
연, 월, 요일이 float 64형태로 나와서 변환 가능한 int16 타입으로 바꾸었음
'''
Time Data
'''
df['Year'] = df['Date'].dt.year.astype('Int16') #연도
df['Month'] = df['Date'].dt.month.astype('Int16') # 월
df['Week'] = df['Date'].dt.isocalendar().week # 주 (week of the year)
df['DayOW'] = df['Date'].dt.dayofweek.astype('Int16') #요일 (day of the week) FYI) Mon 0 - Sun = 6
print(df[['Date', 'Year', 'Month', 'Week', 'DayOW']])
TO-DOs
데이터 시각화, 결측치 처리, 중복 데이터 처리
728x90
'빅데이터(파이썬) > DA_Forecasts for Product Demand' 카테고리의 다른 글
Forecasts for Product Demand (6) 데이터 조사 및 수집 (0) | 2023.01.13 |
---|---|
Forecasts for Product Demand (5) 데이터셋 셋업 (0) | 2023.01.11 |
Forecasts for Product Demand (4) 데이터 정제 (0) | 2023.01.09 |
Forecasts for Product Demand (3) 시계열 기반 데이터 탐색 및 시각화 (0) | 2023.01.03 |
Forecasts for Product Demand (2) 데이터 탐색 및 시각화 (0) | 2022.12.27 |
Comments