#### World's Best AI Learning Platform with profoundly Demanding Certification Programs

Designed by IITian's, only for AI Learners.

Download our e-book of Introduction To Python

How to leave/exit/deactivate a Python virtualenvironment Exception Type: JSONDecodeError at /update/ Exception Value: Expecting value: line 1 column 1 (char 0) How to choosing the right estimator for the machine learning problem? Why not getting result of a as [4, 7,8,3,2] What is lambda in Python? Why is it used? How to implement Queue in python using list? Getting error in user defined function What is use of Heat map ? How to plot heat map? Join Discussion

4 (4,001 Ratings)

220 Learners

Neha Kumawat

a year ago

In this article, we will try to see how we can
perform some operations on our data frame using python libraries like Pandas and
Numpy. We all know how important and useful these python libraries are while we
are performing an Exploratory Data Analysis or any Data Science projects.

Data Operations

Here we will try to learn some basic examples
from each of the two libraries and see how they help us to operate on the
data.

Numpy package is a very important library
provided by python used for any mathematical operation is to be done. This
Package is very important for performing any Machine learning and Deep Learning
tasks.

Numpy stands for N-dimensional array called
ndarray. It describes the collection of items of
the same type. Items in any collections can be accessed using a zero-based
index. An instance of ndarray class can be constructed by different array
creation.

Let’s
see with some examples, how basic ndarray is created using an array function in
Numpy.

```
import numpy as np
arr = np.array([[4, 6], [7, 8]])
print(arr)
```

```
[[4 6]
[7 8]]
```

```
import numpy as np
arr = np.array([1, 2, 3, 4, 5], ndmin = 2)
print(arr)
```

`[[1 2 3 4 5]]`

```
import numpy as np
arr = np.array([1, 2, 3], dtype = complex)
print(arr)
```

`[1.+0.j 2.+0.j 3.+0.j]`

Python pandas library provides many functions
to handles data through Series, Data Frame,
and Panel.

Pandas Series is a one-dimensional labeled array
which is capable of holding data of any type (integer, string, float, python
objects, etc.). The axis labels are collectively known as index.

Now let’s take an
example and understand it in a better way

```
import pandas as pd
import numpy as np
data = np.array(['P','Q','R','S'])
series = pd.Series(data)
print(series)
```

```
0 P
1 Q
2 R
3 S
dtype: object
```

Pandas data frame is a two-dimensional data
structure in python. Here, data is aligned in a tabular form in rows and
columns.

Let’s see how we can create pandas DatFrame.

Let’s see an example

```
import
pandas as pd
data =
{'Name':['Ram', 'Mohan', 'Amit', 'Ricky'],'Age':[23,25,29,36]}
df1 =
pd.DataFrame(data, index=['rank1','rank2','rank3','rank4'])
print(df1)
```

```
Name Age
rank1 Ram 23
rank2 Mohan 25
rank3 Amit 29
rank4 Ricky 36
```

For more blogs/courses on data science, machine learning, artificial intelligence, and new technologies do visit us at** InsideAIML**.

Thanks for reading…

We're Online!

Chat now for any query