Quantcast
Channel: Replace null values in a column corresponding to specific value in another column pandas - Stack Overflow
Browsing all 2 articles
Browse latest View live

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 Article



Replace 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
Browsing all 2 articles
Browse latest View live




Latest Images