0% found this document useful (0 votes)
18 views

Informatics Practices: Data Handling Experiment

The document describes an experiment using Pandas and NumPy to create a NumPy array of the first ten odd numbers, convert it to a Pandas Series, and perform operations like displaying subsets of the series, reversing the order, filtering values, and modifying an element.

Uploaded by

heizaibrahim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Informatics Practices: Data Handling Experiment

The document describes an experiment using Pandas and NumPy to create a NumPy array of the first ten odd numbers, convert it to a Pandas Series, and perform operations like displaying subsets of the series, reversing the order, filtering values, and modifying an element.

Uploaded by

heizaibrahim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

EXPERIMENT 3

DATA HANDLING-PANDAS SERIES (USING NUMPY ARRAY)

Problem Definition

Write a Python program to create a Numpy array. Name the array odd to store the
first ten odd numbers. Create a Pandas Series sod from the Numpy array and
perform the following functions.

1. Display the first five elements of series sodd.


2. Display the last three elements of series sodd.
3. Display series sod in reverse order.
4. Display elements of series sodd that are above 10
5. Display elements of series sodd by multiplying each element by 2
6. Modify the third element of the series to value 0 and display the series.

Program Code

import numpy as np

import pandas as pd

odd=np.arange(1,20,2)

sodd=pd.Series(odd)

print("The Series created is")

print(sodd)

print("The first five elements of the Series")

print(sodd.head())

print("The last three elements of the Series")

print(sodd.tail(3))

print("The Series in reverse order")

print(sodd[::-1])

Heiza Ibrahim Ahadi


print("The elements of the series above 10")

print(sodd[sodd>10])

print("The elements of the series multiplying it by 2")

print(sodd*2)

sodd[2]=0

print("The series after modification")

print(sodd)

Input/Output

The Series created is

0 1

1 3

2 5

3 7

4 9

5 11

6 13

7 15

8 17

9 19

dtype: int32

Heiza Ibrahim Ahadi


The first five elements of the Series

0 1

1 3

2 5

3 7

4 9

dtype: int32

The last three elements of the Series

7 15

8 17

9 19

dtype: int32

The Series in reverse order

9 19

8 17

7 15

6 13

5 11

4 9

3 7

2 5

1 3

0 1

Heiza Ibrahim Ahadi


dtype: int32

The elements of the series above 10

5 11

6 13

7 15

8 17

9 19

dtype: int32

The elements of the series multiplying it by 2

0 2

1 6

2 10

3 14

4 18

5 22

6 26

7 30

8 34

9 38

dtype: int32

Heiza Ibrahim Ahadi

You might also like