<jupyter_start><jupyter_text>시험출력<jupyter_code>l1=[1,2,3,4,5,6,7,8,9,10]
print(l1[4:6])
for line in lines[1:3]:
    print(line)<jupyter_output>[5, 6]
243,050120,2018-01-02,10250,12050,10150,11800,26086769,307823874200,0.145631,-0.00423729,10108,9308.5,8621.17,8720.42,88.8317,-13027931.942863163,300377268,-0.0063048,18544682818.902584,3787360.0,6437619.607910971,423.884,10797.5,1073.04,11611.7,7005.26,10379.8,8274.83,9327.33,13150,8020,10610,11.6865,9820,9964.87,10402.2,585.305,43.1332,0.824498,1.08595,0.66153,31.6801,139.587,-1158.5,181.035,10597.5,12990.0,99.3894,67.2394,0.617452,22.3595,45.645,73.6842,-26.3158,1259.47,9897.76,44.7853,6.24021,42.056

244,050120,2018-01-03,11950,12450,10900,11750,20460474,240410569500,-0.00423729,0.0723404,10538,9448.5,8675.83,8743.33,89.5348,-11047886.07189542,279916794,-0.000901337,15749296173.345072,4355959.690865422,3712347.1053974,422.088,10849.3,1107.11,11976.9,6920.06,10572.5,8362.5,9467.5,13150,8020,10610,11.5532,10120,10239.5,10676.9,684.352,44.7943,0.811475,1.12536,0.748867,31.8566,139.281,-1218.5,214.541,10715,12912.4,99.6947,66.769,0.606881,24.6104,44.5857,72.7096,-27.2904,1435.35[...]<jupyter_text>MIN_MAX SCALING<jupyter_code># min_max 스케일링 전에 전체 기간 범위에 대한 min값과 max값 추출
min_list=[]
max_list=[]
for line in lines[1:]:
    l_list=line.split(',')
    min_list.append(int(l_list[5])) # Low 행
    max_list.append(int(l_list[4])) # High 행
print(max(max_list))
all_max=max(max_list)
print(min(min_list))
all_min=min(min_list)
# min_max 스케일링
# x'= ( x - min(x) ) / ( max(x) - min(x) )
new_list=[]
new_list.append(lines[0])
for line in lines[1:]:
    l_list=line.split(',') #1번째 데이터일 경우 여기서 리스트로 만들고
    mini_list=[]
    for l_num in range(len(l_list)): #0,1,2,8번째 열? 제외하고 스케일링 #리스트 개수를 범위로 해서 스케일링
        if (l_num!=0) & (l_num!=1) & (l_num!=2) & (l_num!=8):
            mini_list.append(str((float(l_list[l_num])- all_min)/(all_max-all_min)))
        else:
            mini_list.append(l_list[l_num])
    new_row=",".join(mini_list)
    new_list.append(new_row)<jupyter_output><empty_output><jupyter_text>100억이상인 데이터 필터링  데이터의 컬럼리스트 만들어내기<jupyter_code>Code_list=new_list[0].split(',') #데이터의 Code리스트
new_code=[]
new_code.append(Code_list[1])
new_code.append(Code_list[2])

for i in range(9, -1, -1):
    for num1 in Code_list[3:]:
        if num1=="Next_Change":
            continue
        else:
            new_code.append('D-'+str(i)+'_'+num1)
new_code.append("Next_Change")
new_code_s=",".join(new_code)<jupyter_output><empty_output><jupyter_text>컬럼명 확인<jupyter_code>print(new_code)
print(len(new_code_s.split(',')))
#new_list사용
new_csv=[]
new_csv.append(new_code_s)#index목록을 새 데이터에 추가
standard=new_list[10].split(',')  #최소 10번째 데이터 이후여야 하므로 기준이 되는 10번째 데이터를 변수에 저장
i=1#현재 몇번째 데이터인지?
for line in new_list[1:]:
    
    new_data=[]
    l_list=line.split(',')
    date=l_list[2].replace("-","") 
     #1번째 변수=코드
    if int(date)>=int(standard[2].replace("-","")): #10번째 데이터가 되기 위한 최소날짜
        now_code=l_list[1]
        pre=new_list[i-9].split(",")
        if pre[1]==now_code: #10개 전 데이터의 코드와 현재 코드 일치한지
            if float(l_list[8])>=1.00E+10:#8번째:traiding_value가 100억이상
                new_data.extend(l_list[1:3]) #2번째
                
                for m in range(i-9,i): #(lines.index(line))=지금데이터번호
                    # 9일 전~당일 데이터를 추가
                    d_list=(new_list[m]).split(',') #m일 전 데이터를 리스트화
                    # 당일 데이터의 index~날짜
                    # 11번째가 Next_change
                    new_data.extend(d_list[3:11])
                    new_data.extend(d_list[12:])  
                new_data.extend(l_list[3:11]) 
                new_data.extend(l_list[12:])  
                new_data.append(l_list[11])
                new_data_str=",".join(new_data) #새로 만들어진 행을 str(콤마(,)구문 행)로
                new_csv.append(new_data_str) #새 파일에 저장될 행 추가
    i+=1<jupyter_output><empty_output><jupyter_text>시험 출력<jupyter_code>#print(len(new_csv[1].split(',')))
print(new_csv[1])<jupyter_output>050120,2018-01-15,0.005914479678521959,0.006967815329193724,0.005855961031262417,0.006821518711044868,15.2655406508561,307823874200,-8.359644428995521e-05,-8.368414518593422e-05,0.0053635266145733666,0.004961310396364354,0.00501939015376945,-3.169855640349075e-05,-7.6238532205229355,175.77663022710502,-8.368535506481819e-05,10852.097440512918,2.2162281571834272,3.7671242285989823,0.00016436951716849334,0.006234869272267954,0.000544246826972649,0.00671132809825515,0.004015701723432681,0.005990436882664845,0.004758636913445654,0.005374545675852339,0.0076115204490486916,0.004609513844634162,0.006125146808656313,-7.684288386915933e-05,0.005662849495305927,0.0057476254595908265,0.006003545059650984,0.00025883090276131935,-5.844070042139278e-05,-8.319918050486377e-05,-8.304618233123077e-05,-8.329454717392971e-05,-6.514289961067544e-05,-1.9972414309681915e-06,-0.0007616201940829455,2.2257567485166982e-05,0.0061178319777488695,0.007517890613433424,-2.552033318177004e-05,-4.4334078275712944e-05[...]<jupyter_text>\n(줄바꿈 표시 삭제)<jupyter_code>error="\n"
for i in range(len(new_csv)):
    new_csv[i]=new_csv[i].replace(error,"")<jupyter_output><empty_output><jupyter_text>새로 만들어진 str행들을 다시 리스트 형태로 저장<jupyter_code>new_array=[]
for new in new_csv:
    new_array.append([new])
print(new_array[1])<jupyter_output>['050120,2018-01-15,0.005914479678521959,0.006967815329193724,0.005855961031262417,0.006821518711044868,15.2655406508561,307823874200,-8.359644428995521e-05,-8.368414518593422e-05,0.0053635266145733666,0.004961310396364354,0.00501939015376945,-3.169855640349075e-05,-7.6238532205229355,175.77663022710502,-8.368535506481819e-05,10852.097440512918,2.2162281571834272,3.7671242285989823,0.00016436951716849334,0.006234869272267954,0.000544246826972649,0.00671132809825515,0.004015701723432681,0.005990436882664845,0.004758636913445654,0.005374545675852339,0.0076115204490486916,0.004609513844634162,0.006125146808656313,-7.684288386915933e-05,0.005662849495305927,0.0057476254595908265,0.006003545059650984,0.00025883090276131935,-5.844070042139278e-05,-8.319918050486377e-05,-8.304618233123077e-05,-8.329454717392971e-05,-6.514289961067544e-05,-1.9972414309681915e-06,-0.0007616201940829455,2.2257567485166982e-05,0.0061178319777488695,0.007517890613433424,-2.552033318177004e-05,-4.4334078275712944e-[...]<jupyter_text>파일 저장<jupyter_code>import numpy as np

np.savetxt("3w_scaling.csv",new_array,fmt='%s', delimiter=',')
# ####메모#######
#                     key를 code로,value를 해당되는 날짜들의 리스트로 해서 위치검색?(시간 오래걸림)
#                     4-딕셔너리-key를 Code로, Value를 날짜로?(value값에 나머지)
#                     4-맨 처음 행의 high, low를 max, min으로 설정하고 다음 행에서 더 크거나 작을 때 업데이트하는 식으로 max,min 값 추출<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16006575997608727, 'fraction_numerical': 0.3888805858616051, 'mean_word_length': 5.012578616352202, 'pattern_counts': {'":': 1, '<': 30, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '5470', 'license': 'MIT', 'n_tokens_mistral': 4854, 'n_tokens_neox': 3744, 'n_words': 262, 'path': '[6w] [jsy07] [capstone_3w]optimization(D-9_D-0).ipynb', 'repo_name': 'GaYounKoh/stock_data', 'size': '6691'}