Python Pandas - 1 || Type A || Sumita Arora || Class 12 || Information Practices || Solution


Q1. What is the significance of Pandas library?


Q2. Name some common data structures of Python's Pandas library.


Q3. How is a Series object different from and similar to ndarrays? Support your answer with examples.


Q4. Write commands to print following details of a Series object seal.
(a) If the series is empty.
(b) Indexes of the series.
(c) The data type of underlying data.
(d) If the series stores any NaN values.



Q5. Given following Series objects:

   S1
0     3
1     5
2     6
4     10
5     12
   S2
0     12
2     10
3     15
4     20
6     27
(a) What will be the result of S1 + S2?
(b) What will be the result of S1 - S2?




Q6. Given a dataframe df as shown below:

    A    B    C
0    15    17    19
1    16    18    20
2    20    21    22

What will be the result of following code statements?
(a) df['C'] = np.NaN
(b) df['C'] = [2, 5]
(c) df['C'] = [12, 15, 27]



Q7. Write code statements to list the following, from a dataframe namely sales.
(a) List only columns 'Item' and 'Revenue'.
(b) List rows from 3 to 7.
(c) List the value of cell in 5th row, 'Item' column.



Q8. How would you add a new column namely 'val' to a dataframe df that has 10 rows in it and has columns as 'Item', 'Qty', ‘Price’? You can choose to put any values of your choice.


Q9. Write code statements for a dataframe df for the following:

(a) Delete an existing column from it.
(b) Delete rows from 3 to 6 from it.
(c) Check if the dataframe has any missing values.
(d) Fill all missing values with 999 in it.



Q10. Write statement(s) to delete a row from a DataFrame.


Q11. Write statement(s) to delete a column from a DataFrame.


Q12. Write statement(s) to change the value at 5th row, 6th column in a DataFrame df.


Q13. Write statement(s) to change the values to 750 at 4th row to 9th row, 7th column in a DataFrame df.



Q14. What is the difference between iloc and loc with respect to a DataFrame?


Q15. What is the difference between iat and at with respect to a DataFrame?



Q16. How would you delete columns from a dataframe?


Q17. How would you delete rows from a dataframe?


Q18. Which function would you use to rename the index/column names in a dataframe?

16 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. Helped to do my holiday homework , thank you

    ReplyDelete
  2. I'm doing my holiday homework rn..n it's definitely helping me out...so glad that i found answers to all my questions at one place...shoutout to @PathWalla

    ReplyDelete
  3. Please add all questions of solution of type A. Doing great Job for students 👍

    ReplyDelete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post