‫So Pandas is a software library written for the Python programming language for data manipulation
‫and analysis.
‫This is specifically for data and information and analysis.
‫First, we need to import pandas.
‫So we'll write import.
‫pandas as pd.
‫If you are using anaconda, Anaconda have automatically install pandas into your system
‫so you don't need to install it separately, you just have to import it into your workspace.
‫for pandas
‫We will be using our customer data.
‫csv file
‫You can find this file in the resources section of this video.
‫So go on, download this file and put this in your folder.
‫We will start by importing a customer.csv file. So we will write data one
‫This is our variable.
‫Then we'll will write a pandas function to import
‫csv
‫That is pd.read_csv
‫Then we provide the location of our csv file
‫Remember to change
‫This backspaces into forward slashes.
‫Then the file name customer.csv
‫And then headers = 0
‫Since our first row contain the header.
‫If we run this, we'll get our table in variable data 1
‫If we write data 1.head, we'll get the first five rows of our data.
‫You can see we have customer id, customer name, segment, age, country, city, state, postal code and
‫the region as our columns.
‫Then we have multiple customer details as rows
‫First is a customer
‫id
‫This is a unique id for each customer.
‫Second column is a customer name.
‫Here we have a customer name, full name.
‫Then that is the segment whether the customer belong
‫to a consumer segment or corporate segment.
‫Then we have a column for age. The age of customer.
‫Then the country, city, state, postal code, region of that customer.
‫If you want to grab more rows, you can provide the number.
‫in this bracket, by default it is five.
‫If you write 10 in the output you will get 10 rows
‫Now, here you are seeing this zero one, two, three, four.
‫This all are the index of this table.
‫For example, 0th rows will be this row.
‫If you want to add our customer id as an index, since our customer id is primary key.
‫We can add it as an index.
‫We'll write this csv file into another data type
‫That is data 2. We'll copy
‫the above command
‫two and we will write another
‫parameter that its index underscore column
‫We are providing the location of index column,and for our data it is customer id.
‫Which is the 0th
‫column of our data.
‫Since this is the first column, the index is zero.
‫That's why we are providing zero.
‫Similar to what we provided for headers
‫So our headers was present in the first row. So I added 0, the location of it.
‫here also our index column is zero.
‫If we run this and again, if we run the head of this.
‫You can see now zero one, two, three, four indexes out of one.
‫Now these are our indexes.
‫These are important and we will discuss about it in a short while.
‫Now head command is used to view the sample of your data.
‫If you want to know statistics of your data, you write data1
‫Dot describe, dot describe it as a keyword.
‫And run this.
‫So there are only two integer values in our data.
‫That's why we are only getting two columns here
‫First is Region
‫And second is post code.
‫Here you can see the total count of value, the mean of age , the standard deviation of age, minimum
‫age, maximum age.
‫These are the percentile value.
‫This is a 25 percentile value.
‫So if you arrange all the age in ascending order, the value presented that 25th percentile of that data
‫is this value.
‫Similarly, this is the 50th percentile, also known as the median value. This is the 70 percentile value of
‫age.
‫And this is the maximum value of age.
‫This we will discuss in univariate analysis, which we will be covering in the later part of this course.
‫There are two ways to Index a data frame.
‫So we discuss earlier while importing this data.
‫We can provide index column, for our data 1index
‫We did not provide any index column for data two our index column
‫is customer id
‫So if we want to view the first row of our data, we have to either use loc
‫Or I loc, if you if we use data one.
‫dot iloc
‫And then we provide zero.
‫What iloc will do is, It will grab the data that is present at the 0th Index of our data frame.
‫So our output is same as what the first row is of our data frame.
‫If we want to use the index column, which we defined while creating our data frame, we have to use loc
‫And in the bracket, if we write the customer id.
‫CG-12520
‫In data 2 we defined our index column as customer id
‫So now we can use loc keyword to get the data of this
‫customer id, If we run this,
‫You can see we are getting all the details of our customer except the customer id. since this
‫is the index column. Similarly.
‫If I don't know this id and I just wanted to grab the first customer
‫I can use.
‫iloc
‫here also
‫I'm getting the same detail, here
‫I was using iloc, with iloc you have to use the serial number zero and so on with loc
‫You can use the index column that you provided earlier
‫So if you know the position you can use, I lock.
‫And if you know the value, you can use the loc.
‫Just like in this 10 data frame, you can also mention multiple values using colon operator.
‫So for example, if I write data 2.iloc
‫0 colon five
‫This will give me the data of first five rows.
‫where, the index, value is zero, one, two, three and four, the number five is excluded from
‫this result.
‫So I'm getting data of this five customer.
‫You can use steps as well, if I write 2
‫And run this.
‫I'm getting only three results since I'm using steps, that's all for panda.
‫We will be using panda a lot more while doing our work and will discuss new topics than in their order.