you can use the lambda
function and pd.apply()
like this:
from countryinfo import CountryInfo
df['Capital'] = df['country'].apply(lambda x : CountryInfo(x).capital()
Here you can put your own df's column name
in place of 'Capital'
and 'country'
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…