CoolFace
Apppublic

Gopal101/Netflix-Data-Analytics

sourceHugging Facebsdupdated 4y agoView on Hugging Face
1likes
app.py105 linesDownload Raw Back to root
1import numpy as np2import pandas as pd3import plotly.express as px 4import matplotlib.pyplot as plt5import plotly.graph_objects as go 6import streamlit as st7import missingno as msno8import seaborn as sns9 10st.set_page_config(layout='wide')11 12def clean_duration_count(value):13    if isinstance(value,float):14        return value15    value_parts = value.split()16    duration_time = value_parts[0].replace(',','')17    return duration_time18 19def clean_dataset(df):20    df['duration'] = df['duration'].apply(clean_duration_count).astype(float)21    return df22 23def load_dataset():24    df = pd.read_csv('data/netflix.csv')25    df = clean_dataset(df)26    return df27 28st.title("Netflix data shown in visuals format")29with st.spinner("loading dataset"):                        30    print("D")31    df=load_dataset()32    33 34movie = df[df['type'] == 'Movie']35tv_show = df[df['type'] == 'TV Show']36 37view_options = ["Dont Show",'Show All','Only Movies','Only Shows']38view_choice = st.sidebar.radio("Select View", view_options)39if view_choice == view_options[0]:40    st.info("View Dataset on the sidebar")41elif view_choice == view_options[1]:42    st.write(df)43elif view_choice == view_options[2]:44    st.write(movie)45elif view_choice == view_options[3]:46    st.write(tv_show)47 48st.header("Yearly release")49all_year_count=df["release_year"].value_counts().reset_index()50fig = px.bar(all_year_count, 'index', 'release_year', title="No of releases respect to years")51movie_year_count=movie["release_year"].value_counts().reset_index()52st.write(movie_year_count)53fig2 = px.bar(movie_year_count, 'index', 'release_year', title="No of Movies releasae respect to years", log_y=True)54show_year_count=tv_show["release_year"].value_counts().reset_index()55fig3 = px.bar(show_year_count, 'index', 'release_year', title="No of shows releasae respect to years",log_y=True)56st.plotly_chart(fig, use_container_width=True)57st.plotly_chart(fig2, use_container_width=True)58st.plotly_chart(fig3, use_container_width=True)59 60fig=plt.figure(figsize=(2,4))61sns.countplot(data=df ,x='type')62 63st.plotly_chart(fig)64 65director_name=df['director'].value_counts().reset_index()66fig=px.area(director_name,'index','director',title="NO of production count respect to director",color='director')67st.plotly_chart(fig, use_container_width=True)68 69df_countries = df['country'].value_counts().reset_index()70fig=px.funnel_area(df_countries.head(n=10),'index','country',title="Top 10 countries have production with count")71st.plotly_chart(fig, use_container_width=True)72 73movie.sort_values('duration',inplace=True, ascending=False)74fig = px.bar(movie, 'title', 'duration', title="Duration of movies", color='release_year')75st.plotly_chart(fig, use_container_width=True)76 77cast_count=df['cast'].value_counts().head(10)78fig=px.bar(cast_count,title='Top 10 most castings')79st.plotly_chart(fig, use_container_width=True)80 81release=df['release_year'].value_counts().head(10)82fig=px.bar(release,title='Top 10 years have more production')83st.plotly_chart(fig, use_container_width=True)84 85tv_show.value_counts()86fig=px.line(tv_show.head(10),'title','duration',title='Top 10 TV shows  have maximum length')87st.plotly_chart(fig, use_container_width=True,)88 89movie.value_counts()90fig=px.line(movie.head(10),'title','duration',title='10 Movies have maximum length')91st.plotly_chart(fig, use_container_width=True)92 93india_df = df[df['country'] =='India'].copy()94fig=px.scatter(india_df.head(n=50),'title', 'director', title='Top 50 Movies released in India  per year 1900-2022',color_discrete_sequence=["red", "green", "blue", "goldenrod", "magenta"],)95st.plotly_chart(fig, use_container_width=True)96 97rating_counts=df["rating"].value_counts().reset_index()98fig=px.bar(rating_counts, 'index', 'rating', title="Ratings counts in netflix",)99st.plotly_chart(fig, use_container_width=True)100 101listed_count=df['listed_in'].value_counts()102fig=px.funnel(listed_count.head(n=10),title='Top 10  category listed' )103st.plotly_chart(fig, use_container_width=True)104 105