0% found this document useful (0 votes)
15 views7 pages

Program 1

The document outlines a series of programming tasks involving the creation and manipulation of Series and DataFrames using Python. It includes operations such as creating Series with specific values and indices, performing arithmetic operations on Series, and managing DataFrames with sales data. The tasks also cover data retrieval, modification, and file operations related to the created DataFrames.

Uploaded by

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

Program 1

The document outlines a series of programming tasks involving the creation and manipulation of Series and DataFrames using Python. It includes operations such as creating Series with specific values and indices, performing arithmetic operations on Series, and managing DataFrames with sales data. The tasks also cover data retrieval, modification, and file operations related to the created DataFrames.

Uploaded by

arvind.pratap47
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

PROGRAM 1

Create the following Series and do the specified operations:

a) EngAlph, having 26 elements with the alphabets as values and default index values.
b) Vowels, having 5 elements with index labels ‘a’, ‘e’, ‘i’, ‘o’ and ‘u’ and all the five values set to
zero. Check if it is an empty series.

c) Friends, from a dictionary having roll numbers of five of your friends as data and their first
name as keys.

d) MTseries, an empty Series. Check if it is an empty series.

e) MonthDays, from a numpy array having the number of days in the 12 months of a year. The
labels should be the month numbers from 1 to 12.
PROGRAM 2
Using the Series created in Program 1, write commands for the following:

a) Set all the values of Vowels to 10 and display the Series.


b) Divide all values of Vowels by 2 and display the Series.
c) Create another series Vowels1 having 5 elements with index labels ‘a’, ‘e’, ‘i’, ‘o’ and ‘u’ having
values [2,5,6,3,8] respectively.
d) Add Vowels and Vowels1 and assign the result to Vowels3.

e) Subtract, Multiply and Divide Vowels by Vowels1.


f) Alter the labels of Vowels1 to [‘A’, ‘E’, ‘I’, ‘O’, ‘U’].

PROGRAM 3
Create the following Data Frame Sales containing year wise sales figures for five sales persons in INR.
Use the years as column labels, and sales person names as row labels.
PROGRAM 4
Use the Data Frame created in Program 3 above to do the following:

a) Display the row labels of Sales.

b) Display the column labels of Sales.

c) Display the data types of each column of Sales.

d) Display the dimensions, shape, size and values of Sales.

e) Display the last two rows of Sales.

f) Display the first two columns of Sales.

g) Create a dictionary using the following data. Use this dictionary to create a Data Frame
Sales2.
h) Check if Sales2 is empty or it contains data.

PROGRAM 5
Use the DataFrame created in Program 3 above to do the following:

a) Append the DataFrame Sales2 to the DataFrame Sales.

b) Change the DataFrame Sales such that it becomes its transpose.

c) Display the sales made by all sales persons in the year 2017.
lu

d) Display the sales made by Madhu and Ankit in the year 2017 and 2018.

e) Display the sales made by Shruti 2016.


f) Add data to Sales for salesman Sumeet where the sales made are [196.2, 37800, 52000,
78438, 38852] in the years [2014, 2015, 2016, 2017, 2018] respectively.

g) Delete the data for the year 2014 from the DataFrame Sales.

h) Delete the data for sales man Kinshuk from the DataFrame Sales.

i) Change the name of the salesperson Ankit to Vivaan and Madhu to Shailesh.

j) Update the sale made by Shailesh in 2018 to 100000.


k) Write the values of DataFrame Sales to a comma separated file [Link] on the disk.
Do not write the row labels and column labels.

l) Read the data in the file [Link] into a DataFrame SalesRetrieved and Display it.
Now update the row labels and column labels of SalesRetrieved to be the same as that of
Sales.

You might also like