더북(TheBook)

<코드>

1. weekday = [0 for i in range(24)]
   weekend = [0 for i in range(24)]
2. for row in data:
    2.1 if row[2] == dong_code:
        2.1.1 time, p = row[1], row[3]
              year, mon, day = int(row[0][:4]), int(row[0][4:6]), int(row[0][6:])
        2.1.2 num = datetime.date(year, mon, day).weekday()
        2.1.3 if num < 5:
                  weekday[time] += p
              else:
                  weekend[time] += p
3. weekday_cnt, weekend_cnt = 0,0
4. for i in range(1, 32):
    4.1 if datetime.date(2019, 12, i).weekday() < 5:
            weekday_cnt += 1
        else:
            weekend_cnt += 1
5. weekday = [w/weekday_cnt for w in weekday]
   weekend = [w/weekend_cnt for w in weekend]
6. plt.plot(range(24), weekday)
   plt.plot(range(24), weekend)
신간 소식 구독하기
뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.