0% found this document useful (0 votes)
81 views2 pages

Practicing Pandas (Questions Only)

This document contains 27 questions about performing operations on pandas DataFrames and series. It involves generating series, creating DataFrames from lists, inserting and deleting columns and rows, updating values, filtering rows, sorting, plotting, and saving DataFrames to CSV files. It also provides 5 Python statements and asks to write the output.

Uploaded by

khushhal2022
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)
81 views2 pages

Practicing Pandas (Questions Only)

This document contains 27 questions about performing operations on pandas DataFrames and series. It involves generating series, creating DataFrames from lists, inserting and deleting columns and rows, updating values, filtering rows, sorting, plotting, and saving DataFrames to CSV files. It also provides 5 Python statements and asks to write the output.

Uploaded by

khushhal2022
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/ 2

Practicing Pandas (Questions)

Q.1. Write a program to generate a series of marks of 10 students. Give grace marks up to 3 marks of
those who are having marks between 30 to 33 marks and print the new list of the marks.
Q.2. Consider the following dataframe named BookDF:
BookID Subject BookTitle Class Publisher Price

0 B0001 Computer Science NCERT Computer Science XII NCERT 270

1 B0002 Computer Science Move fast with CS XI Dhanpat Rai 340

2 B0003 Computer App. Sample Papers X BPB 120

3 B0004 IP NCERT Computer Science XII NCERT 270

4 B0005 Artificial Int Artificial Intelligence IX KIPS 340

5 B0006 IP CBSE Questions Bank XI Oswal Books 299


Write python code for the following:
1) To create this dataframe using lists.
2) To insert a new column named ‘Quantity’ and add values as 5,10,12,10,14,15.
3) To insert a new record of a book named ‘Multimedia’ with the following values.
B0007, Multimedia, AK Sharma, XII, KIPS, 350
4) To display books of IP for class XII.
5) To change the column name ‘Book Title’ to ‘Title’.
6) To change the index name/row name from ‘1’ to ‘1001’.
7) To delete the column named ‘Price’ from the dataframe.
8) To delete the row named ‘B002’ from the dataframe.
9) To change the values of B003 with new values as Computer Applications, Question Bank, IX,
Dhanpat Rai, 300
10) To update the price column with new values as 300, 350, 150, 300, 350, 330.
11) To display the books whose price is more than 250.
12) To display only the BookID, Book Name and Price of the dataframe.
13) To display the records of only Computer Science books from this dataframe.
14) To display the books record from B0002 to B0005.
15) To display the Book Name and Price of B0003.
16) To display display first three rows of the dataframe.
17) To delete last two rows of the dataframe.
18) To display last 4 rows of the dataframe.
19) To delete first 3 rows of the dataframe.
20) To display the dataframe in descending order of the price list.
21) To display the Name and Publisher of books whose price is in between 250 to 300.
22) To plot these data (BookTitle & Price) on line chart and save it with the name ‘mylinechart’
with appropriate Title and labels on both the axis.
23) To plot these data (BookTitle & Price) on Bar Chart and save it with the name ‘mybarchart’
with appropriate Title and labels on both the axis.
24) To add a new column named ‘Discounted’ which must contain the 80% of their price value.
25) To save this dataframe in your computer as ‘books.csv’.
26) To create a new dataframe named myDF from a csv file named ‘xyz.csv’ which is stored at
‘D:\mydata’ in your computer.
27) Assign Price as 600 to all IP books.
Write output for the following Python statements.

1) BookDF.loc [ [True, False, False, False, True, True] ] (Suppose the indexing is Boolean)
2) BookDF [ ‘Price’ > 250]
3) BookDF [ BookDF[ ‘Price’ ] > 250 ]
4) BookDF.Price > 250
5) BookDF [ BookDF.Price > 250 ]

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