[색션3. 작업형1 판다스]의 Section9. 데이터 추가/변경에서 행을 추가할 때는 df .loc[...] 이용해서 하는데 Section5. 새로운 컬럼(열) 추가에서는 그냥 df ['new'] = .... 로 추가를 하더라구요. 이 둘의 차이가 있을까요? 제가 이해한 것은 열을 추가할 때는 df ['new'] = 또는 df.loc[ , 'new'] = 행을 추가할 때는 df.loc['new'] = 이렇게 쓸 수 있고 loc를 사용하면 각각의 데이터를 넣을 수 있지만, 사용하지 않는 경우(Section5)는 일괄적으로 같은 값이 들어간다..인데 맞는지 궁금합니다!
import time from concurrent import futures WORK_LIST = [1000000, 10000000, 100000000, 1000000000] def sum_number(n): return sum(range(1, n + 1)) def main(): start_time = time.time() futures_list = [] with futures.ThreadPoolExecutor() as excecutor: for work in WORK_LIST: future = excecutor.submit(sum_number, work) futures_list.append(future) print(f"Schduled Work: {work} | {future}") print() result = futures.wait(futures_list, timeout=5.0) print(result) end_time = time.time() - start_time print(f"Excecute Time: {end_time:.2f}s / Result: {result}") if __name__ == '__main__': main() 현재 문제점은 최종 출력 시간이 12초정도 걸리는데 중간에 5초 wait 후 print(result)가 호출되는 것이 아니라 12초 후에 아래 코드가 실행될 때 함께 실행되며 모두 정상적으로 finished returned int로 나옵니다. print(f"Excecute Time: {end_time:.2f}s / Result: {result}") 터미널 출력 결과: DoneAndNotDoneFutures(done={<Future at 0x2545b19e780 state=finished returned int>, <Future at 0x2545b123b10 state=finished returned int>, <Future at 0x2545b16f230 state=finished returned int>, <Future at 0x2545b123390 state=finished returned int>}, not_done=set()) Excecute Time: 11.80s / Result: DoneAndNotDoneFutures(done={<Future at 0x2545b19e780 state=finished returned int>, <Future at 0x2545b123b10 state=finished returned int>, <Future at 0x2545b16f230 state=finished returned int>, <Future at 0x2545b123390 state=finished returned int>}, not_done=set())
react (client) + node.js (backend) 와 같은 구성에서는 SOP 에서 설명해주신 '동일 출처 정책' 으로 인해 'fetch' 등을 사용할때 막히는 경우가 종종 있었는데요. 그래서, 이전에는 fe 팀과 be 팀이 개발을 할때 CORS 작업을 항상 했었던걸로 기억합니다. 최근에 많이 사용하는 next.js 는 bff (backend for frontend) 가 중간에 있어서 SOP 로 인한 문제가 거의 없는것 같은데요. (SOP 는 설명해주신것처럼 브라우저 자체의 보안이기 때문에) 이렇게 이해하는게 맞을까요?
Policy Network(Q)와 일반적인 Q-learning 문제에서의 behaviour policy(b)가 각자 하는 역할이 비슷한거 같은데, 만약 틀리다면 추가적인 설명을 부탁드려도 될까요? 왜냐하면, '탐험'의 성격?을 각각의 net과 policy가 수행한다고 생각했습니다. 우선 network관점에서는 특정 행동 결정 규칙에 따라 weight를 형성하는데 이때 그리디 action에 대한 value를 추정(max함수)하는 target network에 비해선 '활용'보다는 '탐험'을 하고 있다고 생각합니다 -> 행동 규칙에 따라 transition을 입력으로 받아 weight를 업데이트 하기 때문. 이로 인해 일반적인 Q-learning에서의 b도 max를 출력하는 target policy, pi대신 e-그리디 정책으로 일정 확률 e로 모든 행동을 선택할 수 있는 기믹을 활용하여 '탐험'을 하기 때문에 위와 같은 생각을 하였습니다.