https://www.datamanim.com/dataset/03_dataq/typeone.html
작업 1유형 — DataManim
Question 각 비디오는 10분 간격으로 구독자수, 좋아요, 싫어요수, 댓글수가 수집된것으로 알려졌다. 공범 EP1의 비디오정보 데이터중 수집간격이 5분 이하, 20분이상인 데이터 구간( 해당 시점 전,후
www.datamanim.com
Question
인기동영상 제작횟수가 많은 채널 상위 10개명을 출력하라 (날짜기준, 중복포함)
import pandas as pd
df = pd.read_csv("https://raw.githubusercontent.com/Datamanim/datarepo/main/youtube/youtube.csv",index_col=0)
df.head()
#value_counts() 구하면 내림차순으로 나옴
df.channelId.value_counts()
df.channelId.value_counts().head(10).index
answer =list(df.loc[df.channelId.isin(df.channelId.value_counts().head(10).index)].channelTitle.unique())
print(answer)
Question
논란으로 인기동영상이 된 케이스를 확인하고 싶다.
dislikes수가 like 수보다 높은 동영상을 제작한 채널을 모두 출력하라
answer =list(df.loc[df.likes < df.dislikes].channelTitle.unique())
print(answer)
Question
채널명을 바꾼 케이스가 있는지 확인하고 싶다.
channelId의 경우 고유값이므로 이를 통해 채널명을 한번이라도 바꾼 채널의 갯수를 구하여라
change = df[['channelTitle','channelId']].drop_duplicates().channelId.value_counts()
change
change = df[['channelTitle','channelId']].drop_duplicates().channelId.value_counts()
target = change[change>1]
print(len(target))
Question
일요일에 인기있었던 영상들중 가장많은 영상 종류(categoryId)는 무엇인가?
df.info()
type(df['trending_date2'][0])
df['trending_date2'] = pd.to_datetime(df['trending_date2'])
answer =df.loc[df['trending_date2'].dt.day_name() =='Sunday'].categoryId.value_counts().index[0]
print(answer)
Question
각 요일별 인기 영상들의 categoryId는 각각 몇개 씩인지 하나의 데이터 프레임으로 표현하라
group = df.groupby([df['trending_date2'].dt.day_name(),'categoryId'],as_index=False).size()
group
group = df.groupby([df['trending_date2'].dt.day_name(),'categoryId'],as_index=False).size()
answer= group.pivot(index='categoryId',columns='trending_date2')
display(answer)
Question
댓글의 수로 (comment_count) 영상 반응에 대한 판단을 할 수 있다.
viewcount대비 댓글수가 가장 높은 영상을 확인하라 (view_count값이 0인 경우는 제외한다)
target2= df.loc[df.view_count!=0]
t = target2.copy()
t['ratio'] = (target2['comment_count']/target2['view_count']).dropna()
t
t.sort_values(by='ratio', ascending=False)
target2= df.loc[df.view_count!=0]
t = target2.copy()
t['ratio'] = (target2['comment_count']/target2['view_count']).dropna()
result = t.sort_values(by='ratio', ascending=False).iloc[0].title
print(result)
Question
댓글의 수로 (comment_count) 영상 반응에 대한 판단을 할 수 있다.
viewcount대비 댓글수가 가장 낮은 영상을 확인하라 (view_counts, ratio값이 0인경우는 제외한다.)
ratio = (df['comment_count'] / df['view_count']).dropna().sort_values()
ratio
ratio = (df['comment_count'] / df['view_count']).dropna().sort_values()
ratio[ratio!=0].index[0]
result= df.iloc[ratio[ratio!=0].index[0]].title
print(result)
Question
like 대비 dislike의 수가 가장 적은 영상은 무엇인가? (like, dislike 값이 0인경우는 제외한다)
target = df.loc[(df.likes !=0) & (df.dislikes !=0)]
num = (target['dislikes']/target['likes']).sort_values().index[0]
num
target = df.loc[(df.likes !=0) & (df.dislikes !=0)]
num = (target['dislikes']/target['likes']).sort_values().index[0]
answer = df.iloc[num].title
print(answer)
Question
가장많은 트렌드 영상을 제작한 채널의 이름은 무엇인가? (날짜기준, 중복포함)
df.loc[df.channelId ==df.channelId.value_counts().index[0]].channelTitle.unique()
answer = df.loc[df.channelId ==df.channelId.value_counts().index[0]].channelTitle.unique()[0]
print(answer)
Question
20회(20일)이상 인기동영상 리스트에 포함된 동영상의 숫자는?
df[['title','channelId']]
df[['title','channelId']].value_counts()
answer= (df[['title','channelId']].value_counts()>=20).sum()
print(answer)
'빅데이터분석기사 > 작업 1유형' 카테고리의 다른 글
지역구 에너지 소비량 데이터 (0) | 2022.08.15 |
---|---|
전세계 행복도 지표 데이터 (0) | 2022.08.15 |
서울시 따릉이 이용정보 데이터 (0) | 2022.08.15 |
월드컵 출전선수 골기록 데이터 (0) | 2022.08.14 |
유튜브 공범 컨텐츠 동영상 데이터 (0) | 2022.08.14 |