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

Pandas Practice Questions

This document contains 17 multiple choice and coding questions related to Python Pandas and NumPy. The questions cover topics such as array indexing and slicing, correlation, stacking arrays, data types, reshaping arrays, grouping data, conditional selection, plotting histograms, minimums/maximums, sorting, plotting multiple data sets, and grouping/aggregating dataframes. The last few questions involve more complex coding tasks like finding maximum marks by gender after grouping, checking if arrays can be stacked, and building a menu-driven math operation program on arrays.

Uploaded by

Abu Shahma
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
627 views

Pandas Practice Questions

This document contains 17 multiple choice and coding questions related to Python Pandas and NumPy. The questions cover topics such as array indexing and slicing, correlation, stacking arrays, data types, reshaping arrays, grouping data, conditional selection, plotting histograms, minimums/maximums, sorting, plotting multiple data sets, and grouping/aggregating dataframes. The last few questions involve more complex coding tasks like finding maximum marks by gender after grouping, checking if arrays can be stacked, and building a menu-driven math operation program on arrays.

Uploaded by

Abu Shahma
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Sarvodaya Public School Python Pandas Questions Set-2

Azamgarh By Ashraf Jamal

Q1. Find the output of following program. 1

import numpy as np
d=np.array([10,20,30,40,50,60,70])
print(d[2:-2])
Q2. Name the method to find correlation between two arrays. Give syntax 1
Q3. ______ is the method used to horizontally stack an array over another array. 1
Q4. _______ attribute of the arange method is used to assign a data type to the array being 1
created.
Q5. Write the missing statement in the following code: 1

import numpy as np
arr1= np.arange(12)
ar = _________ # statement to reshape the above array to (3,4) size
print(ar)
Q6. Name the method used to group the data in a dataframe on the basis of one or more 1
column.
Q7. Write the output of the following questions: 2

import numpy as np
array1=np.array([10,12,14,16,18,20,22])
array2=np.array([10,12,15,16,12,20,12])
a=(np.where(array1==array2))
print(array2[a])

Q8. Differentiate between a list and an array in python


OR 2
How are series and dataframes different in python?

Q9. Rashmi wants to display the last three rows of the dataframedf and has written the 2
following code:
df.tail()
But last 5 rows are being displayed. Identify the error and rewrite the correct code so that
last 3
rows get displayed.
OR
Write the command to add a new column in the last placenamed “Salary” from the list
Sal=[40000,50000,60000] in an existing dataframe named EMP already having 2 columns.

Q10. When pivot_table() method used instead of pivot? Give example. 2


Q11. Differentiate between line chart and a scatter plot 2
Q12. Write a python code using pyplot to create a histogram for the following data set: 2
Marks=[38,10,15,25,28,35,47,49,50,63,67,53]
Give appropriate labels and titles
Q13. Give the output for the following code on dataframes: 2
(Assumption : all necessary files are already imported and data frame already created)
Dataframe : Student
Roll_No Name Age Marks
1 Mahesh 13 83
2 Alia 15 75
3 Kavya 14 45
4 Abhishek 14 60
5 Sarvar 12 90
6 Priya 11 78
7 Arun 17 89

print(Student[‘Age’].min() – Student[‘Age’].max())
print(Student.count())

Q14. What is the difference between sort_index() and sort_values() methods in pandas library? 2
Q15. Write a program plot two data sets on the same bar graph. First data set represents the 4
marks of Boys and second data set represents marks of girls in a class
Boy_mark=[34,67,87,90,34]
Girl_mark=[45,80,23,56,99]
Proper labels, title and legends should be given to the plot.
Q16. Create the following dataframe. Group the data on the basis of gender and find the name 4
of the boy who got maximum marks
Rollno Name Gender Marks
1 Nilansh M 480
2 Mili F 400
3 Josh M 450
4 Kumar M 240
5 Ishita F 305
6 Mitali F 398
7 Kevin M 401
Q17.W Write a program to check whether an array A can be vertically or horizontally stacked or both 4
on an
array B.
OR
Write a menu based program to perform four basic mathematical operations on two 1D numpy
arrays based on user’s choice.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy