Visualizing Netflix Data Using Python!
Visualizing Netflix Data Using Python!
Image Source
Introduction
We can say that data visualization is basically a graphical representation of data and information. It is
mainly used for data cleaning, exploratory data analysis, and proper effective communication with
business stakeholders. Right now the demand for data scientists is on the rise. Day by day we are shifting
towards a data-driven world. It is highly beneficial to be able to make decisions from data and use the skill
of visualization to tell stories about what, when, where, and how data might lead us to a fruitful outcome.
Data visualization is going to change the way our analysts work with data. They’re going to be expected to respond to issues more
rapidly. And they’ll need to be able to dig for more insights – look at data differently, more imaginatively. Data visualization will promote
that creative data exploration. -Simon Samuel
Table of contents
Our eyes are drawn to colours and patterns. We can quickly recognize blue from yellow, circle from a
square. Data visualization is a form of visual art that not only grabs our interests but also keeps our eyes
on the message. We can literally narrate our entire numerical data to the stakeholders in a form of
captivating graphs with the help of data visualization.
Right now we are living in “an age of Big data” trillions of rows of data are being generated every day. Data
visualization helps us in curating data into a form that is easily understandable and also helps in
highlighting a specific portion. Plain graphs are too boring for anyone to notice and even fail to keep the
reader engaged. Hence, today we will be seeing how to create some mind-blowing visualization using
matplotlib and seaborn.
It is a graph that represents a specific category of data with rectangular bars with length and height
proportional to the values they represent.
Syntax: matplotlib.pyplot.barh(y,width,height)
Parameters:
Parameters:
By the end of this article, you will be able to create some awesome data visualization using matplotlib and
seaborn. So without further ado, let’s get started.
*Feel free to skip this part if you are already aware of these libraries…
Matplotlib: It is a plotting library for the Python programming language and it has numerical mathematics
extension Numpy. It provides an object-oriented API for embedding plots into applications using general-
purpose GUI toolkits like Tkinter, QT, WxPython, or GTX. (Source)
Seaborn: It is an amazing visualization library for statistical graphics plotting in python. It provides
beautiful default styles and color palettes to make statistical plots more attractive. It is built on top of
matplotlib library and is also closely integrated into the data structures from pandas. The aim of seaborn is
to make visualization the central part of exploring and understanding data. It also provides dataset-
oriented APIs so that we can switch between different visual representations for the same variables for a
better understanding of the dataset. (Source)
Numpy: It is a library for python that supports multi-dimensional arrays and matrices with many high-level
mathematical operations to perform on these arrays and matrices.
Pandas: It is a powerful, flexible, and easy-to-use data manipulation tool for the python programming
language.
Data pre-processing
import pandas as pd import numpy as np import matplotlib.pyplot as plt %matplotlib inline import seaborn as
sns
for i in df.columns: null_rate = df[i].isna().sum()/len(df) * 100 if null_rate > 0 : print("{} null rate:
{}%".format(i,round(null_rate,2)))
director missing percentage: 30.68% cast missing percentage: 9.22% country missing percentage: 6.51%
Here we will be replacing the missing country with the most country (mode), cast, and director with no
data.
df.drop_duplicates(inplace=True)
Now we are done with missing values, but the dates are still not quite right…
Always use a color palette, it is a great way in achieving good integrity and helps us to give a professional
look keeping all the readers engaged.
palette",loc='left',fontfamily='serif',fontsize=15,y=1.2) plt.show()
Steps:
//Annontate code
Boom!!
from datetime import datetime tl_dates = [ "1997nFounded", "1998nMail Services", "2003nGoes Public",
"2007nStreming service", "2016nGoes Global", "2021nNetflix & Chill" ] tl_x = [1,2,4,5.3,8,9]
Boom!!
df['country']
As can we see that in 7782 and 7786 there are multi countries in a single column so what we will do is we
will create another column that will store only the first country.
Now we will replace some of the country names with their short form.
[:10]
output:
['top','left','right']: ax.spines[s].set_visible(False)
from wordcloud import WordCloud import random from PIL import Image import matplotlib
Keep in Mind
1. Always make sure that you keep your data visualizations organized and Coherent.
2. Make sure to use proper colours to represent and differentiate information. Colours can be a key factor
in a reader’s decisions.
3. Use high contrast colours and annotate the elements of your data visualization properly.
4. Never distort the data, data visualization is said to be great when it tells the story clearly without
distortions.
5. Never use a graphical representation that does not represent the data set accurately(For eg: 3D pie
charts).
. Your Data visualization should be easy to comprehend at a glance.
7. Never forget that our agenda of data visualization is to enhance the data with the help of design, not
just draw attention to the design itself.
Conclusion
So, we wrap up our first tutorial on Netflix Data visualization – Part 1 here. There is still a problem with this
visualization i.e. these are not interactive, the ones we can build with plotly and cufflinks.
Sometimes data visualization should be captivating and attention-grabbing which I think we have achieved
here even if it isn’t precise. So by customizing our visualization like what we did here reader’s eye is drawn
exactly where we want.
I hope enjoyed reading the article. If you found it useful, please share it among your friends on social
media too. For any queries and suggestions feel free to ping me here in the comments or you can directly
reach me through email.
Connect me on LinkedIn
https://www.linkedin.com/in/karanpradhan266
Email: [email protected]
Thank You !!
The media shown in this ar ticle are not owned by Analytics Vidhya and are used at the Author’s
discretion.
Karan Pradhan