Recode with np.select
Goal: Create a new column based on data from another column. Use Pandas.DataFrame and Numpy.select to create the new column. You can see the full program at Google Colaboratory There are three basic steps to accomplish the goal. Define the conditions Define the values Use np.select to apply the conditions and values. First, create a list containing each "condition," then create a list containing each return v alue. The goal is to correlate each condition with each value. What does that mean? It means if the first condition in the "conditions" list evaluates as True, return the first value in the "values" list. An error will occur when the lists have different index counts. For example, if there are five conditions and 4 values. This condition example below has two useful applications we would be remiss if we didn't take note: The first is the use of .isnull() == True. The second is th...