My solution is the same of jezrael, but with one more step, based on an essay I made with the null problem.
I've added one more row for a pfv without values.
data = [['0-50','StoreSale','Clothes','8-Apr','above 100','FatimaStore','Shoes'],
['0-50','StoreSale','Clothes','8-Apr','0-50','DiscountWorld','Clothes'],
['51-100','CleanShop','Clothes','4-Dec','51-100','BetterUncle','Shoes'],
['0-50','StoreSale','Clothes','12-Apr','above 100','','Clothes']]
First step is to handle nulls. 'df' is the DataFrame.
df = df.replace('', np.nan)
v_4 v5 s_5 vt_5 ex_5 pfv pfv_cat
0 0-50 StoreSale Clothes 8-Apr above 100 FatimaStore Shoes
1 0-50 StoreSale Clothes 8-Apr 0-50 DiscountWorld Clothes
2 51-100 CleanShop Clothes 4-Dec 51-100 BetterUncle Shoes
3 0-50 StoreSale Clothes 12-Apr above 100 NaN Clothes
Now let's update the v5 column.
The command says that we will replace v5 for pfv, but if pfv is NaN we will replace with the current value of v5.
df['v5'] = df['pfv'].fillna(df['v5'])
print(df)
v_4 v5 s_5 vt_5 ex_5 pfv pfv_cat
0 0-50 FatimaStore Clothes 8-Apr above 100 FatimaStore Shoes
1 0-50 DiscountWorld Clothes 8-Apr 0-50 DiscountWorld Clothes
2 51-100 BetterUncle Clothes 4-Dec 51-100 BetterUncle Shoes
3 0-50 StoreSale Clothes 12-Apr above 100 NaN Clothes
DF[numpy.isnan(DF["pfv"])]["v_5 "] =DF["pfv"]NaNorNones ?df.loc[df['pfv'].ne('null'), 'v5'] = df["pfv"]working for you?