본문 바로가기

Data Analysis/Kaggle

[Kaggle] Nexfilx movies and TV shows 데이터 분석 3 (EDA / 시각화 / Review)

728x90

이전 내용은 아래 글에서 확인 하실 수 있습니다.

[Data Analysis/Kaggle] - [Kaggle] Nexfilx movies and TV shows 데이터 분석 1 (데이터 확인 / 질문)

 

[Kaggle] Nexfilx movies and TV shows 데이터 분석 1 (데이터 확인 / 질문)

Nexfilx movies and TV shows 데이터셋 분석 분석 목적 : 넷플릭스 컨텐츠 분석으로 트렌드 파악 자료 출처 : https://www.kaggle.com/shivamb/netflix-shows Netflix Movies and TV Shows Listings of movi..

sks8410.tistory.com

[Data Analysis/Kaggle] - [Kaggle] Nexfilx movies and TV shows 데이터 분석 2 (데이터 전처리)

 

[Kaggle] Nexfilx movies and TV shows 데이터 분석 2 (데이터 전처리)

이전 내용은 아래 글에서 확인하실 수 있습니다. [Data Analysis/Kaggle] - [Kaggle] Nexfilx movies and TV shows 데이터 분석 1 (데이터 확인 / 질문) [Kaggle] Nexfilx movies and TV shows 데이터 분석 1 (데..

sks8410.tistory.com

4. EDA & Visualization

4-1 넷플릭스에 등록된 작품 중 어느 타입이 가장 많을까?  

# type 별 등록 수 시각화

nf_type = nf["type"].value_counts()

fig = px.bar(nf_type, x = nf_type.index, y = nf_type.values,
            color = nf_type.index,
            text = nf_type.values)

fig.update_traces(
    textposition = "outside",
    textfont_color = "black"
)

fig.update_layout(
    title = dict(
        text = "<b>타입별 넷플릭스 등록 수</b>",
        font_size = 20
    ),
    
    xaxis = dict(
        title = "Type"
    ),
    
    yaxis = dict(
        title = "등록 수"
    ),
    
    showlegend = False,
    template = "plotly_white"    
)

fig.show()

Movie 가 6,126편, TV Show 가 2,664편으로 Movie 가 약 2.3배 더 많이 등록되어 있습니다.

4-2 어느 나라에서 제작된 작품이 가장 많을까?  

# 전체 타입 중 제작 국가별 작품 수 top20 확인

nf["new_country"].value_counts().head(20)

 

 

# 전체 타입 중 제작 국가별 작품 수 top20 시각화

nf_country_top20 = nf["new_country"].value_counts().head(20)

fig = px.bar(nf_country_top20, y = nf_country_top20.index, x = nf_country_top20.values,
            orientation = "h", color = nf_country_top20.index,
            text = nf_country_top20.values)

fig.update_traces(    
    textfont_color = "white"
)

fig.update_layout(
    title = dict(
        text = "<b>제작 국가별 작품 수 Top20</b>",
        font_size = 20
    ),
    
    xaxis = dict(
        title = "작품 수"
    ),
    
    yaxis = dict(
        title = "국가명"
    ),
    
    showlegend = False,
    template = "plotly_white"
)

fig.show()

미국 작품이 총 3,202개로 넷플릭스에 가장 많이 등록되어 있습니다.
국가를 모르는 작품을 제외하면 한국은 작품 수 211개로 7번째로 넷플릭스에 작품이 많은 국가입니다.

 

 

# 국가별 Movie 등록 수 top20 시각화 

nf_movie_top20 = nf[nf["type"] == "Movie"]["new_country"].value_counts().head(20)

fig = px.bar(nf_movie_top20, y = nf_movie_top20.index, x = nf_movie_top20.values,
            orientation = "h", color = nf_movie_top20.index,
            text = nf_movie_top20.values)

fig.update_traces(    
    textfont_color = "white"
)

fig.update_layout(
    title = dict(
        text = "<b>제작 국가별 Movie 작품 수 Top20</b>",
        font_size = 20
    ),
    
    xaxis = dict(
        title = "작품 수"
    ),
    
    yaxis = dict(
        title = "국가명"
    ),
    
    showlegend = False,
    template = "plotly_white"
)

fig.show()

미국 Movie 작품이 2,361개로 가장 많이 넷플릭스에 등록되어 있습니다.

 

 

# 국가별 TV Show 등록 수 top20 시각화 

nf_tv_top20 = nf[nf["type"] == "TV Show"]["new_country"].value_counts().head(20)

fig = px.bar(nf_tv_top20, y = nf_tv_top20.index, x = nf_tv_top20.values,
            orientation = "h", color = nf_tv_top20.index,
            text = nf_tv_top20.values)

fig.update_traces(    
    textfont_color = "white"
)

fig.update_layout(
    title = dict(
        text = "<b>제작 국가별 TV Show 작품 수 Top20</b>",
        font_size = 20
    ),
    
    xaxis = dict(
        title = "작품 수"
    ),
    
    yaxis = dict(
        title = "국가명"
    ),
    
    showlegend = False,
    template = "plotly_white"
)

fig.show()

미국 TV Show 작품이 841개로 가장 많이 넷플릭스에 등록되어 있습니다.
한국은 TV Show 작품이 164개로 Unknown 국가를 제외하면 4번째로 넷플릭스에 TV Show 가 많은 국가입니다.

4-3 넷플릭스에는 언제 등록된 작품이 많을까? (연/월)  

# 연도별 등록 작품 수 확인

nf["year_added"].value_counts()

 

 

# 연도별 등록 작품 수 시각화

nf_year = nf["year_added"].value_counts().reset_index().rename(columns = {"index" : "year", "year_added" : "count"})

fig = px.bar(nf_year, x = "year", y = "count",
            color = "count", color_continuous_scale = px.colors.sequential.Bluered,
            text = "count")

fig.update_traces(
    textposition = "outside"    
)

fig.update_layout(
    title = dict(
        text = "<b>연도별 넷플릭스 등록 작품 수</b>",
        font_size = 20
    ),
    
    xaxis = dict(
        title = "연도",
        dtick = 1
    ),
    
    yaxis = dict(
        title = "작품 수"
    ),
    
    template = "plotly_white"    
)

fig.show()

2016년부터 넷플릭스 작품 수가 크게 증가 했으며, 2019년에 2,016개로 가장 많은 작품이 등록 되었습니다.

 

 

# 월별 등록 작품 수 확인

nf["month_added"].value_counts()

 

 

# 월별 등록 작품 수 시각화

nf_month = nf["month_added"].value_counts().reset_index().rename(columns = {"index" : "month", "month_added" : "count"})
order = ["January", "February", "March", "April", "May", "June", "July",
         "August", "September", "October", "November", "December"]


fig = px.bar(nf_month, x = "month", y = "count",
            color = "count", color_continuous_scale = px.colors.sequential.Bluered,
            text = "count")


fig.update_traces(
    textposition = "outside",
)

fig.update_layout(
    title = dict(
        text = "<b>월별 넷플릭스 등록 작품 수</b>",
        font_size = 20
    ),
    
    xaxis = dict(
        title = "월",
        dtick = 1,
        categoryorder = "array",
        categoryarray = order
    ),
    
    yaxis = dict(
        title = "작품 수"
    ),
    
    template = "plotly_white"    
)

fig.show()

7월에 가장 많은 작품이 넷플릭스에 등록 되었고, 2월, 5월에 등록 작품 수가 적지만 전체적으로 크게 차이가 나지 않습니다.

4-4 관람 등급은 어떤 것이 가장 많을까? 

# 관람 등급별 작품 수 집계 함수 선언

def generate_rating(nf):  
    nf_rating = nf.groupby(["rating", "rating_ages"]).agg({"show_id" : "count"}).reset_index()
    nf_rating = nf_rating[nf_rating["show_id"] != 0] # show_id 집계 값이 0이 아닌 데이터만 사용
    nf_rating.columns = ["rating", "rating_ages", "count"] # 컬럼명 변경
    nf_rating = nf_rating.sort_values("rating_ages") # target_ages 종류별 정리
    return nf_rating

 

# 전체 작품에 대한 관람 등급별 작품 수 확인

nf_rating = generate_rating(nf)
nf_rating

 

 

# 전체 작품에 대한 관람 등급별 작품 수 시각화

fig = px.bar(nf_rating, x = "rating", y = "count", color = "rating_ages",
            text = "count")

fig.update_traces(
    textposition = "outside"
)

fig.update_layout(
    title = dict(
        text = "<b>넷플릭스 관람 등급별 작품 수</b>",
        font_size = 20
    ),
    
    xaxis = dict(
        title = "관람 등급"
    ),
    
    yaxis = dict(
        title = "작품 수"
    ),
    
    legend_title_text = "관람 ",
    template = "plotly_white"
)

fig.show()

 

 

# 전체 작품에 대한 관람 등급별 작품 수 시각화

fig = px.bar(nf_rating, x = "rating", y = "count", color = "rating_ages",
            text = "count")

fig.update_traces(
    textposition = "outside"
)

fig.update_layout(
    title = dict(
        text = "<b>넷플릭스 관람 등급별 작품 수</b>",
        font_size = 20
    ),
    
    xaxis = dict(
        title = "관람 등급"
    ),
    
    yaxis = dict(
        title = "작품 수"
    ),
    
    legend_title_text = "관람 ",
    template = "plotly_white"
)

fig.show()

Movie, TV Show 모두 성인 등급의 작품이 절반 가까이 차지하고 있습니다.

4-5 작품 시간(길이)는 어느정도 되는 것이 가장 많을까?  

# Movie 작품 확인

nf_type_movie = nf[nf["type"] == "Movie"]

# 상영시간을 duration_bin 컬럼에 범위를 설정하여 등록
movie_duration = nf_type_movie["duration"].str.split(" ").str[0].astype(int)
nf_type_movie.loc[movie_duration.loc[movie_duration < 90].index, "duration_bin"] = "1시간 30분 미만"
nf_type_movie.loc[movie_duration.loc[(movie_duration >= 90) & (movie_duration < 150)].index, "duration_bin"] = "1시간 30분 이상 ~ 2시간 30분 미만"
nf_type_movie.loc[movie_duration.loc[movie_duration >= 150].index, "duration_bin"] = "2시간 30분 이상"

print(nf_type_movie.shape)
nf_type_movie.head()

 

 

fig = px.histogram(x = nf_type_movie["duration_bin"], color = nf_type_movie["duration_bin"])

fig.update_layout(
    title = dict(
        text = "<b>넷플릭스 Movie 시간</b>",
        font_size = 20
    ),
    
    xaxis = dict(
        title = "작품 시간",
        categoryorder = "array",
        categoryarray = ["1시간 30분 미만", "1시간 30분 이상 ~ 2시간 30분 미만", "2시간 30분 이상"]
    ),
    
    yaxis = dict(
        title = "작품 수"
    ),
    
    template = "plotly_white"
)

fig.show()

Movie 는 작품 시간이 1시간 30분 이상 ~ 2시간 30분 미만인 작품이 제일 많습니다.

 

 

# TV Show 작품 확인

nf_tv = nf[nf["type"] == "TV Show"]

fig = px.histogram(x = nf_tv["duration"])

fig.update_layout(
    title = dict(
        text = "<b>넷플릭스 TV Show 길이</b>",
        font_size = 20
    ),
        
    xaxis = dict(
        title = "작품 길이",
        categoryorder = "total descending"
    ),
    
    yaxis = dict(
        title = "작품 수"
    ),
    
    template = "plotly_white"
)

fig.show()

TV Show 는 대부분 시즌 1까지 있습니다.

4-6 어떤 장르가 가장 많을까?  

# Movie 장르 수 확인

nf_movie_genre = nf[nf["type"] == "Movie"]

nf_movie_genre["genre"].value_counts()

 

 

# Movie 장르 수 시각화

fig = px.bar(y = nf_movie_genre["genre"].value_counts().sort_values().index,
             x = nf_movie_genre["genre"].value_counts().sort_values().values,
             orientation = "h", color = nf_movie_genre["genre"].value_counts().index,
             text = nf_movie_genre["genre"].value_counts().sort_values().values)

fig.update_traces(
    textposition = "outside"
)

fig.update_layout(
    title = dict(
        text = "<b>넷플릭스 Movie 장르 수</b>",
        font_size = 20        
    ),
    
    xaxis = dict(
        title = "장르 수"
    ),
    
    yaxis = dict(
        title = "장르"
    ),    
    
    showlegend = False,
    template = "plotly_white"
)

fig.show()

Movie 장르에는 드라마가 제일 많습니다.

 

 

# 연도별 Movie 장르 등록 시점 시각화

nf_movie_genre_year = nf_movie_genre.groupby(["year_added", "genre"])["show_id"].count().reset_index()
nf_movie_genre_year.columns = ['year_added', 'genre', 'count']

fig = px.sunburst(nf_movie_genre_year, path=['year_added', 'genre'], values='count', color='year_added')

fig.update_layout(
    title = dict(
        text = "<b>연도별 Movie 장르 등록 시점</b>",
        font_size = 20
    )    
)

fig.show()

2016년부터 본격적으로 Movie 가 등록되기 시작했으며 Drama, Comedies 가 매년 가장 많이 등록되고 있습니다.

 

 

# TV Show 장르 수 확인

nf_tv_genre = nf[nf["type"] == "TV Show"]

nf_tv_genre["genre"].value_counts()

 

 

# TV Show 장르 수 시각화

fig = px.bar(y = nf_tv_genre["genre"].value_counts().sort_values().index,
             x = nf_tv_genre["genre"].value_counts().sort_values().values,
             orientation = "h", color = nf_tv_genre["genre"].value_counts().index,
             text = nf_tv_genre["genre"].value_counts().sort_values().values)

fig.update_traces(
    textposition = "outside"
)

fig.update_layout(
    title = dict(
        text = "<b>넷플릭스 TV Show 장르 수</b>",
        font_size = 20        
    ),
    
    xaxis = dict(
        title = "장르 수"
    ),
    
    yaxis = dict(
        title = "장르"
    ),    
    
    showlegend = False,
    template = "plotly_white"
)

fig.show()

TV Show 장르에서는 International TV Show 가 가장 많습니다.

 

 

# 연도별 TV Show 장르 등록 시점 시각화

nf_tv_genre_year = nf_tv_genre.groupby(["year_added", "genre"])["show_id"].count().reset_index()
nf_tv_genre_year.columns = ['year_added', 'genre', 'count']

fig = px.sunburst(nf_tv_genre_year, path=['year_added', 'genre'], values='count', color='year_added')

fig.update_layout(
    title = dict(
        text = "<b>연도별 TV Show 장르 등록 시점</b>",
        font_size = 20
    )    
)

fig.show()

2016년부터 본격적으로 TV Show 가 등록되기 시작했으며 International TV Shows, Crime TV Shows, Kids' TV 가 매년 가장 많이 등록되고 있습니다.

5. Review

1) 넷플릭스에 등록된 작품 중 어느 타입이 많을까?  
   - Movie 가 6,126편, TV Show 가 2,664편으로 Movie 가 약 2.3배 더 많이 등록되어 있습니다.

2) 어느 나라에서 제작된 작품이 가장 많을까? 
   - 미국 작품이 총 3,202개(Movie 2,361개, TV Show 841개)로 넷플릭스에 가장 많이 등록되어 있습니다.
   - 한국 작품은 총 211개(Movie 47개, TV Show 164개)로 Unknown 국가를 제외하고 7번째로 넷플릭스에 작품이 많은 국가입니다.

3) 넷플릭스에는 언제 등록된 작품이 많을까? (연/월)
   - 2016년부터 넷플릭스 작품 수가 크게 증가 했으며, 2019년에 2,016개로 가장 많은 작품이 등록 되었습니다.
   - 7월에 가장 많은 작품이 넷플릭스에 등록 되었고 2월, 5월이 등록 작품 수가 적지만 전체적으로 크게 차이나지 않습니다.

4) 관람 등급은 어떤 것이 가장 많을까? 
   - Movie, TV Show 모두 성인 등급의 작품이 절반 가까이 차지하고 있습니다.

5) 작품 시간(길이)는 어느정도 되는 것이 가장 많을까? 
   - Movie 는 시간 1시간 30분 이상 ~ 2시간 30분 미만인 작품이 제일 많습니다.
   - TV Show 는 대부분 시즌 1까지 있습니다.

6) 어떤 장르가 가장 많을까? 
   - Movie 장르에서는 드라마가 가장 많습니다.
   - 2016년부터 본격적으로 Movie 장르가 등록되기 시작했으며 Drama, Comedies 가 매년 가장 많이 등록되고 있습니다.
   - TV Show 장르에서는 International TV Show 가 가장 많습니다.
  - 2016년부터 본격적으로 TV Show 장르가 등록되기 시작했으며 International TV Shows, Crime TV Shows, Kids' TV 가 매년 가장 많이 등록되고 있습니다.

728x90