Pandas plays with data : Chapter Two

Hello guys, in the previous blog we learn some basic commands/operations of pandas which is used in data science or in python and in today’s blog we are going to learn some more basic commands/operations and also we are going to learn how we can change the one data type to another data type and if you didn’t saw my blog, i suggest you should to through the link for better understanding, for my previous blog just click here.

I hope you guys got the point from chapter one and now let’s start where we left

> Read only first 10 rows

By the “nrow” we can read rows as many as we want

> Output

In this we read only 10 rows if you can read as much you want

> Read only specific columns

Here i use “nrows” for countable data so i can show you

> Output

Here we read the some specific columns

Or you can use head() also if you want to print/read only top 5 values

> Read text file

A computer file which is structured as sequence of lines of electronic test.

Here we read the txt file

> Output

now after update we use read_csv instead of read_table

> Read excel file

These file helps to store the data in spreadsheets, which we are used to store the financial data.

Here we read the file of extension .xlsx

> Output

Here we are read the excel file

> Read sas files

SAS stands for Statistical Analysis Software, contain the source code for a program.

Here we read the value of sas file

> Output

Here are the value

Now we are going to learn how we can convert one type data to another type of data but for this first we have to import the os(operating system) with the help of this we are able to convert one type to another type, and for this we have to create a folder where the converted file are stored and we also have to give its path.

In this first we have import the OS and os.chdir is used to change the current directory to another path and then we start to change the type of the data.

> Output

Here the os is imported

Here we can see the file which was converted into different type they got saved on the path which we gave when we import the OS.

so, with these two blogs we learn some basic operations of pandas which will be very useful when you are working on the data, i hope you find it interesting and i hope you gain some knowledge through my blogs and if you want more click here.

Stay tuned with us, Thanks

Leave A Comment