각 에피소드의 시작날짜(년-월-일)를 에피소드 이름과 묶어 데이터 프레임으로 만들고 출력하라
# s
date_sort = video.sort_values('ct',ascending=True).drop_duplicates('videopk')
date_sort['date'] = date_sort['ct'].dt.date
date_sort[['date', 'videoname']]
#
start_date = video.sort_values(['ct','videoname']).drop_duplicates('videoname')[['ct','videoname']]
start_date['date'] = start_date.ct.dt.date
answer = start_date[['date','videoname']]
display(answer)
#
date_sort = video.sort_values(['videoname','ct'],ascending=True)
date_sort = date_sort.drop_duplicates(['videoname'], keep='first')
date_sort['date'] = date_sort['ct'].dt.date
date_sort[['date', 'videoname']]
“공범” 컨텐츠의 경우 19:00시에 공개 되는것으로 알려져있다. 공개된 날의 21시의 viewcnt, ct, videoname 으로 구성된 데이터 프레임을 viewcnt를 내림차순으로 정렬하여 출력하라
날짜가 아닌 시간(하위 분류)을 기준으로 추출해서 중복제거
#
video['time'] = video['ct'].dt.hour
ans = video[video['time']== 21].sort_values(['videoname','ct']).drop_duplicates('videoname').sort_values('viewcnt',ascending=False)[['videoname','viewcnt','ct']]
ans.reset_index(drop=True)
#
video['time']= video.ct.dt.hour
answer = video.loc[video['time'] ==21] \
.sort_values(['videoname','ct'])\
.drop_duplicates('videoname') \
.sort_values('viewcnt',ascending=False)[['videoname','viewcnt','ct']]\
.reset_index(drop=True)
display(answer)
#
video_9 = video.sort_values(['videoname','ct'], ascending=True)
video_9 = video_9[video_9['ct'].dt.hour == 21]
video_9 = video_9.drop_duplicates('videoname', keep='first')
video_9 = video_9.sort_values('viewcnt', ascending=True)
video_9[['viewcnt','ct','videoname']]
video 정보의 가장 최근 데이터들에서 각 에피소드의 싫어요/좋아요 비율을 ratio 컬럼으로 만들고 videoname, ratio로 구성된 데이터 프레임을 ratio를 오름차순으로 정렬하라
# s
latest = video.sort_values('ct', ascending=False).drop_duplicates('videopk')
latest['ratio'] = latest['dislikecnt'] / latest['likecnt']
latest.sort_values('ratio', ascending=True)[['videoname','ratio']]
#
target = video.sort_values('ct').drop_duplicates('videoname',keep='last')
target['ratio'] =target['dislikecnt'] / target['likecnt']
answer = target.sort_values('ratio')[['videoname','ratio']].reset_index(drop=True)
answer
video 데이터 중에서 중복되는 데이터가 존재한다. 중복되는 각 데이터의 시간대와 videoname 을 구하여라
# s
video[video.duplicated()][['videoname','ct']]
#
answer = video[video.index.isin(set(video.index) - set(video.drop_duplicates().index))]
result = answer[['videoname','ct']]
display(result)
```~~