Pandas:10 minutes 15 basics Part 1

3+
Source : kindpng

Pandas is another powerful and flexible library of Python which is mainly used for Data Management, Data Analysis, etc. Pandas are often considered as a replacement for the much-used data or database management tools or platform like MS-Excel & SQL, although many other tools data or database management tools like Tableau, PowerBI have joined the race, with the diversity, flexibility, and popularity of Python, Data Scientists have switched to Pandas library, especially those who are new in this domain. 

Why I say Pandas might be considered as a replacement for a powerful database management platform like SQL is because Pandas as a package is also useful for using SQL-like functions such as joining, merging, sorting, etc of data frames. To learn Machine Learning, one definitely needs to know the basics of Pandas.

Let’s start with some cool Pandas techniques. 

importing Pandas as a package:

Create a list using NumPy and then create a series in Pandas:

Creation of lists:

Creation of series:

Accessing individual entries in a series:

We can also add labels to the series entries:

In the above screenshot, ‘data=mylist’ defines the data I have entered as the variable ‘mylist’ above and ‘index=mylabels’ represents the data labels I want to include in my index column.

We can use without including ‘data’ & ‘index’ and directly write the variables as parameters, the pd.Series function will take ‘data’ & ‘index’ by default:

Use of mathematical functions on series:

Use of Concat function to combine series and create a data frame:

Creation of data frame using the random function:

Assigning data labels and rows to columns:

Accessing individual series in a data frame(row and columns):

Just like arrays or lists in NumPy, we can apply logical indexing in data frames as well:

Adding another column in the data frame:

Removing a column from the data frame:

In the above screenshot, ‘axis=1’ argument denotes columns and ‘inplace= True’ means that data frame has to make changes permanently.

Removing a row from the data frame:

Removing a data frame’s index labels:

These were some of the remote basics covered to get you started with Pandas, in Part 2 of the article we will be discussing more on Pandas, we will be discussing more functions like merge, join to combine the data frames, creation of pivot tables, etc. Keep upskilling and keep sharing and stay safe, stay indoors, and don’t forget t subscribe to receive weekly updates.

For more guides on Pandas visit https://pandas.pydata.org/ . All the screenshots have been taken through Jupyter Notebook(https://jupyter.org/) on Anaconda platform. Install Ananconda using this link https://www.anaconda.com/

For more NumPy tutorials Part 1, click here and for Part 2, click here .

close
3+

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

DMCA.com Protection Status