Now that you have a basic understanding
of pandas, and you know how to use
Jupyter Notebooks, we can go ahead and
learn how to load various kinds of files
in Python, using Pandas and Jupyter. So
I've got five files here, they contain
exactly the same datasets, and this is a
text version, or let me open the xml
version that will show a pretty overview
of data as you can see. So we've got
7 lines of code including the
header, we have also 7 columns. So
it's just some basic data of
supermarkets. So ID, Address,
City, State, Country, and the Name of the
supermarket, and Number of Employees.
[No audio]
And similarly, we have exactly some of
the same data but in different formats.
So we have csv, and csv means comma
separated values. So it's basically a
text file where the values, the columns
are separated by commas, as you can see
here, so every column is separated by
comma, but it has a csv extension, and
it can be opened with Excel. So if I
open this now, you'll see the same
dataset that you saw in the xlsx file. We
also have the same data in separated by
semi colons. As you can see in here,
[No audio]
and yeah, if
you're working with data, you're
probably familiar with these kinds of
files. So this is how to store data, you
need to have some conventions, and using
such convention, then you use another
programs such as Python, to load these
data. So when you load a csv file,
Python knows that the values will be
separated by commas, and it knows how to
separate them. It knows how to extract
values. So we open all these one by one.
We also have a json file,
[No audio]
which is yet another format to store data, and looks like a
Python dictionary actually. So we will
learn how to convert them to a Pandas
dataframe as well. So all these will be
converted to Pandas Dataframes.
And yeah, I'll go ahead and start Jupyter.
jupyter notebook. Here are my files, I'll go
ahead and create a new Jupyter Notebook
for Python 3. Before I go ahead and
load those files in Python, there's a
trick I do usually, I import os, and then
os.listdir and Alt Enter
execute, that's when you go to the next line.
And what you get is you get a list of
files and folders as well, or file names
that you have in the current directory.
So now I don't have to switch to my
folder to look at the names, I have
everything in here. Now I can go ahead
and import pandas.
[No audio]
And let's start loading
these files one by one. Let's say df1,
so dataframe 1, and that will be
equal to pandas.read_csv,
[No audio]
and then you have to pass the name of the
file that you want to open, supermarkets.csv,
and just Enter and maybe want
to print that out, so df there, and you know,
what we got here is, so we loaded the
dataframe first, and then we printed
that out, so that we got this table, nice
table in there. That's how easy it is to
load data from csv file. Now the benefit
of having the data in Python is it once
you load them in Python, you can do many
many operations with your data. You can
do statistics and add new columns.
You can merge columns, you can add
the numbers form column to the
numbers of the other columns, and at the
end, you can export those data back to
formats like csv, Excel, etc. So we're
going to do that later. But first, let's
see how we load data from several file
formats in the next videos.