Practice Adding and Deleting Columns - 4.7 | Chapter 4: Understanding Pandas for Machine Learning | Machine Learning Basics
K12 Students

Academics

AI-Powered learning for Grades 8–12, aligned with major Indian and international curricula.

Academics
Professionals

Professional Courses

Industry-relevant training in Business, Technology, and Design to help professionals and graduates upskill for real-world careers.

Professional Courses
Games

Interactive Games

Fun, engaging games to boost memory, math fluency, typing speed, and English skillsβ€”perfect for learners of all ages.

games

Practice Questions

Test your understanding with targeted questions related to the topic.

Question 1

Easy

How do you add a new column named 'Height' with values [5.5, 6.0, 5.8]?

πŸ’‘ Hint: Remember to use the DataFrame variable and assign the values.

Question 2

Easy

What command would you use to delete a column named 'Weight'?

πŸ’‘ Hint: Use the drop method, which takes column names as parameters.

Practice 4 more questions and get performance evaluation

Interactive Quizzes

Engage in quick quizzes to reinforce what you've learned and check your comprehension.

Question 1

What method is used to add a new column in a Pandas DataFrame?

  • assign()
  • add_column()
  • df['new_column'] = values

πŸ’‘ Hint: Think about how you normally assign values in Python.

Question 2

True or False: The drop() method can remove multiple columns at once.

  • True
  • False

πŸ’‘ Hint: Recall how we've handled multiple columns in discussions.

Solve 2 more questions and get performance evaluation

Challenge Problems

Push your limits with challenges.

Question 1

Create a DataFrame with three columns: 'Product', 'Price', and 'Sales'. Add a new column 'Profit' calculated as Price - Sales.

πŸ’‘ Hint: Make sure to perform the subtraction correctly to get the profit.

Question 2

Given a DataFrame with multiple columns, write code that removes any column whose name starts with 'temp_'.

πŸ’‘ Hint: Use list comprehension to generate the list of columns to drop.

Challenge and get performance evaluation