Hi, welcome back. When you're doing data
analysis, the first thing you want to do
is you want to familiarize yourself with
your data using the tool, the data
analysis tool that you have chosen to
use for your particular project. In this
case, the tool is Python. So what we're
going to do in this video is we are
going to load the data into Python using
a Jupyter Notebook. And then look
at those data and extract some very
basic information about the data, such
as looking at what the column names we have,
how many rows we have, and other simple
attributes of our data. So let's do
that. I'd like to let you know that I
created an empty folder named
review_analysis, and I put the
reviews.csv file in that folder.
You can find this reviews.csv
file attached to this lecture so as the
lecture resource, so please download
that and place it in a folder just like
I did. And then you should be able to
locate that folder from the Jupyter
homepage, which is localhost:8888/tree.
So I created that folder directly
in my users folder. So this is the
folder, I can click that and here is
reviews.csv file. In your case,
you can create this wherever you want, and then
locate it using this directory tree here.
[No audio]
While I am in this folder from Jupyter, I can go to
the New dropdown list and go to Python 3 to
create a new Jupyter Notebook. So the
Jupyter Notebook has been created, I can
rename this to something else, the name
of the Jupyter Notebook. Let's keep
it simple and say reviews, Rename and
that will get a .ipynb extension.
Let me make some more room here. So that
you see more code. I'm going to toggle
the header off, and now let's start
coding. The very first thing we want to
do, of course, is import pandas, the
library that is used to perform data
analysis with Python, and then we want
to create a variable which is going to
hold the data, that is equal to
pandas.read, since we are working with a
csv file, the method we want to use
out of the pandas library is read_csv.
In parentheses, we want to pass in
single quotes or double quotes, whatever
you like, the path to the csv file. Now
if you don't type in the name correctly,
you're going to get an error. So let me
try to execute this cell using Control
Enter if you are on Windows, or Command
Enter if you are on Mac, and as I warned you
I got an error, it says No such file
or directory, because I mistyped the
file. So reviews. This time if I
execute, I don't get an error, that
means data was loaded successfully. And
I can press Escape B Enter and call the data variable
and Control Enter again to see the DataFrame.
[No audio]
So we can see that we have 1, 2, 3, 4 columns, and
we also have this index column here added by pandas
automatically. Basically, its a range
of numbers starting from 0. So that
is the first row of our data. This
one in here, that has this index of 0.
And it ends at the last row, you can see
that this is the first row, second,
third, fourth, five row and then Jupyter is
not displaying the rows after row
five, because there are a lot of rows
and it'd be impractical to see them
here. However, you get to see the last
five rows of the DataFrame. And that
gives you an overview of the DataFrame.
However, what I like to do instead is just printout
the head of the DataFrame, which is the first
[No audio]
rows only. So the first five rows, that gives you
a more compact view. It gives you an idea
what columns you have and what kind of
rows you have also. So it's good to have
a head of the DataFrame displayed in here.
Then we can press Escape B and create a
new cell here, Enter to write some other code.
You can get the shape of the DataFrame
by accessing the shape property.
So that is a method with parentheses,
that is a property, it doesn't need
parentheses, and then you get to the
shape of the DataFrame which is basically the
number of rows and the number of columns.
[No audio]
You see 1, 2, 3, 4 columns.
[No audio]
You might also want to B Enter, display
[No audio]
the columns that your DataFrame has.
Even though we have them there, this is
yet an other way to see the names of the
columns by accessing the columns
property. Then next, usually, when you
are working with data, you have some
specific columns that you are interested
about, which could be one column or
more. In this case, we might be
interested to see an overview of the
Rating column to see where the minimum
rating is and what the maximum rating
is, and the distribution of those
ratings, and have them as a graph here
displayed here. So that we can have a
better understanding of our data. So I'm
going to do Escape B, Enter and
data.hist. So this will be a histogram
with parentheses. We are interested to
see the distribution of the ratings.
Therefore I enter the Rating column here, I say string.
[No audio]
Execute, and we get this graph. Let me explain
you, what that graph means. What this means is
that, for example, let's start from the
right. This bar here, this first bar
means that we have around 24,000
5 star reviews ratings. You see, for example,
we have this, this is a 5.0 star rating.
So we have around 24,000, 5 star ratings in
the whole DataFrame. And in total, we have
45,000 of those in total. Then the next this bar here,
[No audio]
these are 4.5 star ratings like that one in there.
And we have around, let's say 7000s of
those, then we have 4 star ratings,
around 9000s, perhaps 3.5 star ratings
in here. This is 3 star ratings.
It's about 2000. Then we have 2.5 star
ratings, this one here, 2 star
ratings, 1.5 star ratings. That's the
lowest number among all the ratings.
So people don't leave a lot of 1.5 star
ratings. And we also have this 1 star
ratings in here. It's not the best
graph. I don't like it personally, but
it's a quick way. So that's you know,
how your data are distributed. You know
that's okay, we have data from 1 to 5
and 5 is the most occurring value in
your data. And that's about this
lecture we saw, you can get an overview
of your DataFrame. In the next lecture,
we are going to zoom in into our DataFrame to actually
we would be able to select particular rows, or particular
slices of our DataFrame to see individual values.
So in other words, we are going to use
Python to navigate through our data and
select particular sections of the data and
display them. So I'll see you in the next video.