Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Pandas HELP!! I need help mapping values from a column in a pandas dataframe to binary (strings). For example, in the dataset below I

Python Pandas HELP!!

I need help mapping values from a column in a pandas dataframe to binary (strings). For example, in the dataset below

image text in transcribed

I want to map values higher than 150 from column 'Sell' to 'Yes', and those less than 150 to 'No', so that the new 'Sell' column will look like:

image text in transcribed

It is a large dataset so please provide a solution that is NOT MANUAL, but automatically maps all values to either 'Yes' or 'No'. Thanks!!!

In [2]: df.head() Out[2] : Sell "List" 0 142 160 1 175 180 2 129 132 3 138 140 4 232 240 In [2]: df.head() Out[2]: Sell "List" 0 No 160 1 Yes 180 N No 132 3 No 140 4 Yes 240

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Contemporary Issues In Database Design And Information Systems Development

Authors: Keng Siau

1st Edition

1599042894, 978-1599042893

More Books

Students also viewed these Databases questions