通过过滤数据框分配列

I want to assign a particular value of 1 to feature country_US if country's value is 'US'. Here is what two thing I tried but getting warning and X_test is also not updated with country_US feature.

X_test[X_test['country']=='US].loc[:,'country_US']=1

X_test.loc[X_test['country']=='US].loc[:,'country_US']=1

警告 -

C:\ Users \ DELL \ Anaconda3 \ lib \ site-packages \ pandas \ core \ indexing.py:671:SettingWithCopyWarning: 试图在DataFrame的切片副本上设置一个值

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy self._setitem_with_indexer(indexer, value)