파이썬 sklearn 다중회귀분석 - paisseon sklearn dajunghoegwibunseog

#아까 제외한 행들이 있으므로 index 다시 지정

#https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.reset_index.html

df["First_auction_date"]= df["First_auction_date"].str.split(" ", n = 1, expand =True)

df["Final_auction_date"]= df["Final_auction_date"].str.split(" ", n = 1, expand =True)

#https://www.geeksforgeeks.org/python-pandas-split-strings-into-two-list-columns-using-str-split/

#요일 출력을 위해 ' '로 분리하고 datetime.strftime에 차례로 입력하여 요일을 출력해보도록한다.

from datetime import datetime

a_s=df["First_auction_date"].str.split("-",expand = True)

a_e=df["Final_auction_date"].str.split("-", expand = True)

#split 결과가 object 형태로 반환되어 numeric으로 바꾸기

a_s[0]=pd.to_numeric(a_s[0])

a_s[1]=pd.to_numeric(a_s[1])

a_s[2]=pd.to_numeric(a_s[2])

a_e[0]=pd.to_numeric(a_e[0])

a_e[1]=pd.to_numeric(a_e[1])

a_e[2]=pd.to_numeric(a_e[2])

df['auction_start_weekday']=0

df['auction_end_weekday']=0

for i in range(0,len(df)):

df['auction_start_weekday'][i]=datetime(a_s[0][i], a_s[1][i], a_s[2][i]).weekday()

df['auction_end_weekday'][i]=datetime(a_e[0][i],a_e[1][i],a_e[2][i]).weekday()

#https://stackoverflow.com/questions/9847213/how-do-i-get-the-day-of-week-given-a-date ##monday-sunday로 글자로 기록

#https://docs.python.org/2/library/datetime.html ##숫자로 기록, 0=Monday