text_html_output_1.png
import collections

import itertools

import numpy as np

import pandas as pd

import seaborn as sns

anime_df = pd.read_csv('../input/anime.csv', header=0)
rating_df = pd.read_csv('../input/rating.csv', header=0)

anime_df.shape

anime_df.dtypes

anime_df.isnull().sum()

anime_df = anime_df.replace('Unknown', np.nan)
anime_df_nnull = anime_df.dropna()

anime_df_nnull.type.unique()

type_count_series = anime_df_nnull['type'].value_counts()
type_df = type_count_series.to_frame()
type_df

type_df = type_df.reset_index()
type_df.columns = ['type', 'counts']
type_df

type_members_series = anime_df_nnull.groupby('type')['members'].agg('sum').reset_index()
type_members_df = pd.DataFrame(data=type_members_series)
type_members_df = type_members_df.sort_values('members')

anime_df_nnull['episodes'] = anime_df_nnull['episodes'].astype(int)

genre_values_list = anime_df_nnull['genre'].apply(lambda x: x.split(', ')).values.tolist()
genre_value_chain = itertools.chain(*genre_values_list)
genre_counter = collections.Counter(genre_value_chain)
genre_df = pd.DataFrame.from_dict(genre_counter, orient='index').reset_index()
genre_df.columns = ['genre', 'count']
genre_df = genre_df.sort_values('count', ascending=False)
sns.barplot(x=genre_df['count'], y=genre_df['genre'])