Ip File

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 25

01.Create a pandas series from a dictionary of values.

Display 3 top rows using head ().


Ans.
2.Create a pandas Series from an ndarray of values.
0

Display 3 Rows from bottom using tail().


Ans.
03. Draw the following bar graph representing the
number of students in each class.

Ans.
4. Create a Dataframe using a ndarray of values and show
mean, median, maximum value, minimum value, mode.
05. Create a Data Frame quarterly sales where each row
contains the item category, item name, and expenditure.
Group the rows by the category, and print the total
expenditure per category.
Ans.
06. Filter out rows based on different criteria such as
duplicate rows.
Ans.
07. Find the sum of each column, or find the column with
the lowest mean.
Ans.
8. Do the following :

1. locate the 3 largest values in a dataframe

2. subtract the mean of a row from each element of the row in a dataframe.

3. replace all negative values in a dataframe with a 0.

4. replace all missing values in a dataframe with a 999.

Ans.
9.A dictionary Grade contains the following data: Grade={'Name':['Rashmi', 'Harsh', 'Ganesh', 'Priya',
'Vivek', 'Anita', 'karthik'], 'Grade':['A1', 'A2', 'B1', 'A1', 'B2', 'A2', 'A1']}

Write statements for the following:

a. Create dataFrame called GR.

b. Find the output of GR.iloc[0:5] and GR[0:5}

c. Add a column called percentage with following data: [92, 89, None, 95, 68, None, 93]

d. Rearrange the columns as Name, Percentage and grade

e. Drop the column (i.e. Grade) by name

f. Delete the 3rd and 5th rows

g. What does the following will do?

i. Gr.drop(0, axis=0)

ii. Gr.drop(0, axis="index")

iii. Gr.drop([0, 1, 2, 3], axis=0 ans.


10. Importing and exporting data between pandas and
CSV file

result csv
11. Implement Describe method on a dataframe display
its output.
12. Write a program to iterate over a dataframe
containing names and marks, which then calculates
grades as per marks and adds them to the grade column.
Marks Grade
Marks>=90 A+
Marks 70-90 A
Marks 60-69 B
Marks 50-59 C
Marks 40-49 D
Marks <40 F
13. Consider a DataFrame ndf as shown below:

Name Sex position City Age Project Budget


0 Rabia F Manager Banglore 30 13 48
1 Evan M Programmer Ndelhi 27 17 13
2 Jia F Manager Chennai 32 16 32
3 Lalit M Manager Mumbai 40 20 21
4 Jaspreet M Programmer Chennai 28 21 17
5 Suji F Programmer Bangalore 32 14 10

i. Create the above dataframe and do the following


ii. Print the details of the youngest employee in the dataframe
iii. Print the details of the employee handling the maximum number of projects
Ans12
ans13
14. Given the school result data, analyse the performance
of the students on different parameters, e.g subject wise
or class wise.
15. Histogram with bars for age
group[10,15,20,25,30,35,40,45,50] and
avarage_age_of_population = [10,20,20,40,40,40,40].

Note: above histogram is drawn with bars as per bins already decided for age
group
[10,15,20,25,30,35,40,45,50] and height of bars as 1 point for 10 as 10 is one time
only
, 2 points for 20 because these values are for two time and 4 points for 40
because it is
for four times.
16. Generally ten different prices of a stock are stored.
However, for ABC Co only 5 prices are available for a
dat:[74.25, 76.06, 69.5, 72.55, 81.5] Write a program to
create a bar chart with the given prices:
 The graph should be plotted between the limits -2
to 10 on x-axis
There should be tick for every potted point

You might also like