Answer by rommy for Replace null values in a column corresponding to specific...
You can try below code if ffill is not an option, df['Region'] = np.select((df.Country.isin(['USA', 'MEX']), df.Country == 'UK'), ('Americas', 'Europe'), df.Region)
View ArticleReplace null values in a column corresponding to specific value in another...
I have a dataframe as below :import pandas as pddf = pd.DataFrame({'Country': ['USA','USA','MEX','IND','UK','UK','UK'],'Region': ['Americas','NaN','NaN','Asia','Europe','NaN','NaN'],'Flower':...
View Article
More Pages to Explore .....