In this lecture, we will learn how to import a word, name cities fine.
In them
for this group audience.
We will be importing Bailey to tell female, but that's it.
And Biton, this dataset is publicly available on trade forms like Gagen.
And you can also download the CSP file from the resources section of this lecture.
This dataset have two columns.
First column is for dates and second column.
As for the number of.
But now let's import this database.
We will lose Bandas reads GSV Method.
So let's just first import Banda's and then we are importing this dataset using not greed's.
Yes we method since this CSU file is available in the working directory off my Python library.
I am not providing the complete but I'm just providing the file name if you want.
You can also provide the whole part of this file instead of just the file name.
And then my file have had.
That's that's why I'm writing headers equate to zero zero means that heads are available at the 08 index.
That is the first rule of my dataset.
If you had file does not contain any headers, you have to write headers equate to none known.
Let's just import this dataset and we are saving this dataset into an object called data frame.
So we are creating a data frame object of Ponder's with the name Duty-Free.
Let's just run it.
Now to look at the first five records of this newly created.
We can just call head matter.
We right to frame.
And you can see we have the first five rows of data set.
The first column is of dates.
The second column is our birds.
And we have index from zero and so on.
Now, let's check the database of this data column.
We want to know whether PANDAS is identifying this text as a string or as a date.
For that, we can write Dufrene.
Then they'd call up.
And then in more detail,
you can see the output we are getting is awe or sense for object or in other word strings.
So currently one does is not identifying this big text as a date.
It is identifying this value as a string for what?
Future data analysis.
We want this value as dates, not as a string to do that.
We can use a parameter that is past date using this parameter.
We can mention the column which contains dates, and Banda's will automatically identify the format
of that column and convert it into a debate format.
So let's create another dappling.
I'm calling is D.F. to.
And simply, we are writing the same statement, but this time we are using additional parameter of
pass state and then we are mentioning that at all to zero through.
That is the fourth straw.
There are dates in that column.
So suppose if my dates are in second column, I have to write one here.
I have to mention the index which contains the dates.
Let us run this.
So my beef to deter fame is ready.
Know now to take the first fibros I can ride the f blue dot peg.
You can see the output is similar, but this thing, this dates are in the form of the time for.
Not in the form of the string.
For me to check that, I can just straight up frame the do.
Then I want to look at the date, that type of date column and just play the detailed.
You can see earlier the fundamentals of the tape or which is sense for string.
This time the phone my boys Emmett Emmett stands for.
They paint for me.
Now, you can see that does has automatically identified the format of these dates.
So here the four on my days.
Why, why?
Why, why m-m didi.
And Fondas has automatically identified that me for me and of that, if the format was of MMD Levi Way.
In that case also pandas would have automatically identified in the format.
But in some cases, pandas have some trouble in identifying the format.
In those cases, you can use DEET password.
But I think that as well.
So only in cases where you are finding problems in loading data and loading the time data using this
method on the in those cases you have to use date parser for date parser.
You have to mention the format of fear data that is present in columns.
So, for example, in this case, my data is available in the form of why year, month and days?
Then I have to mention the format of such dates.
For example, here, this percentage by a percentage and percentage B means that if my date is nineteen
ninety nine slash well slash zero one, then we have a space for our.
Then there is a colon.
Then there is a minute and then there is a second.
So if my date is in the form of this index affirmation the format in this way.
So for date poza you have to first create a date parser function where you have to mention the format
and then pass this function as an argument for date underscore parser parameter.
You can also look at the link that I have provided you to look at all the directives that are available
with this date parser.
So suppose if your months are in this format, you have to write percentage B instead of percentage
M.
So just look at all this tapes.
And create your own big parcel function.
And then use it to import your dates and date time for me.
But for most cases, you are not going to need it.
Fondas will automatically identify the date time formic for you.
Now, another way to import daytime data is by using cities instead of data fames.
So here we were creating data frames.
Our indexes were in the form of numerical data.
But there is one more matter to import time cities where we will have dates or date time values as our
index.
And then a single column for the value of their cities.
So, for example, let's just import this same data as the cities as well.
So I am creating another object that we are calling cities.
And here also I am using the same method be read out routes CSP.
Then we have to mention the finally then headers and then we are using pastorate equate to zero since
our first column contains dates.
And then for cities, we need to make our date time data as our indexed column.
So I am writing index underscore call equate to zero.
That is our first column is the index for our cities.
And then to convert this data frame in two cities, I can read it squeeze equate to grow just on this.
So my series is really.
Let's look at the first five aloose.
You can see these are the first five values.
You can notice now the city's name is, but there is no individual column name.
The values that are contained in this series is OK.
But so instead of column name, we have our city's name as Bert's.
The big type is in digits since this second column contains integer values.
And for this series, we have big time values as our indexes.
And this second column that is the column is the values of our cities.
So the on the difference between data frame and cities is that in data frame we have numerical indexes
from zero to the land of ordinary Dufrene.
We have two columns.
First one is dead.
And the second one is birth in cities.
We have indexes as a World Time Series data and the values corresponding to those indexes as the values
of cities.
Now let's look at some different attributes of their data frame.
And the cities that we have created.
To look at the size of Ford data from cities, we can right dot shaped my head.
So c.D or Chip?
Sidis is our object name here.
We are just using dot ship attribute.
Similarly, what do Dufferin words D.F. do?
Using dot ship.
You can see we have it on 365 values in our cities.
Since cities only have one single column.
You cannot have more than one column in your cities.
Let's say we are not getting the number of columns.
Whereas for the data frame that we have created, we have two columns, first one for date and second
one for the birth.
That's why we are getting 365 Pommer too.
There are 365 rows and two columns.
Now let's look at how to get that subset of our cities or our data frame.
So far, cities, if I want values of January of 1959, I can just ride cities and I can mention the
year and the month.
Well, you remember, this is the advantage of using the time format and sort of a string for me here.
I'm not mentioning the days value.
I will automatically get all the values of January 1959.
If you're on this, you can see that I'm getting all the values from day one to day 31.
This is the way to slice your data.
In case of cities, if you just write 1959 here, you will get data for all the months and all the days.
Similarly for data frame, we can write condition.
So here we want the values from the data frame.
We're the data frame date.
Value is more than this.
And data frame data value is less than this.
So for this 21 days from 2nd Gen to 21st Gen.
If I want to get a value, I can write like this.
Here also, this is the advantage of using date time for me.
If we were using string format, this was just a string for Bandas and it will not be able to identify
whether January two is between these two values or not.
But since we are using data format, Banda's can identify that Denbury five lies between first gen and
21st Gen.
Let's run this as well.
You can see the result is as expected.
We have values from 2nd Gen build 21st Gen.
So in case of series you can just write them on values and you will get all the values.
But for the top frame, you have to mention the range of dates between which you want the data now to
find important statistics about your data frame or series.
You can use Don describe method.
So just write your series or data frame, name and use or describe method here.
You will get values of the number of homes, mean standard deviation, minimum value, the value present
at the 25th percentile of the value presented.
The 15th percentile and the value presented in the fifth percentile.
And the maximum value of your cities.
So for our cities, the total number of observations are 365.
The mean of all these values is forty one point nine eight.
Standard deviation is seven point three.
The minimum values frantically, the maximum value is 73.
And then we have that 25 feet and 75 percent value as well.
The name of this series is Births and the D type is flawed.
Similarly, this is the stats for our cities for data frame can again use Dort describe method here.
Also, you will get all these values for your columns which contain numerical value.
So the statistics are the same since we have loaded the same data.
So this is the way to load your data and to get some basic statistics about your data.
Now, to summarize, you can load your data as a data frame.
And in case, if you have only one column for euro value, you can also imported as your cities four
dates.
You need to take special care to import it in our day time format.
Using part state and mentioning the column name for Seabees and data frame containing time series data,
you can use all the basic methods of pandas data Dufrene such as head for looking at the first five
values shape for looking at the size of your data frame and or describe metric to look at some basic
statistics about your affair.
That's all for this video.
Thank you.