Answered step by step
Verified Expert Solution
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
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:
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started