How to write value from a dataframe column to another column based in a condition?

Juan Rodrigues

I'm having some bad time here trying to figured out how to set a column-based in a condition. Basically, I want to copy the value from column "Customer" to the rows of the column "Call Ref", if the row is different from 'Enterprise' and 'Client'.

Follow the code I'm trying:

df_OCB['Call Ref'] = np.select([np.logical_and(df_OCB['Call Ref'] != 'Enterprise',df_OCB['Call Ref'] != 'Client')], df_OCB['Costomer'],default='')

Please, Does anyone have a good solution to share with me?

Antoine

Have you tried with np.where()?

df_OCB['Call Ref'] = np.where((df_OCB['Call Ref'] != 'Enterprise') & (df_OCB['Call Ref'] != 'Client'), df_OCB['Customer'],'')

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to find minimum value in a column based on condition in an another column of a dataframe?

Setting value for dataframe column from another dataframe based on condition

how to add column in dataframe based on some condition from another column?

How to match column value in a dataframe based on condition in another dataframe?

Extract Value From Pandas Dataframe Based On Condition in Another Column

Get value from another dataframe column based on condition

Copy a column value from another dataframe based on a condition

how to set the value from a column to another based on a condition

How to fill the value into a new column based on the condition of another column in Pandas dataframe?

Fill DataFrame based on value from another column

How to add a new column based another column condition in pandas dataframe

How to populate a dataframe column based on condition met in another column

Assign value to a column from another column based on condition

Create a column with value from another column based on condition

Obtain value from a column based off condition in another column in R?

Selecting a column value based on the value from another dataframe column

Adding a new column to a dataframe from the values of another dataframe based on a condition

Create custom column based on condition of how another column value starts with

How to replace NaN value in column in Dataframe based on values from another column in same dataframe

how to write a query to set the value of a column based on another column

How to replace the values in a dataframe column based on another dataframe condition

Select from column in dataframe based on value in another column

Applying function in new dataframe column based on value from another column

update pandas dataframe column with value from another dataframe with condition

How to apply an operation in a column based on a condition from another column

How to update a column based on date condition from another column?

How to select a column's values from a dataframe based on a datetime condition in another dataframe?

pandas add column to dataframe having the value from another row based on condition

How to fill column values from dataframe column names based on condition?