【发布时间】:2020-06-29 09:03:53
【问题描述】:
我正在寻找根据索引值设置不同的条件。
我有以下索引值:
country
Uk
Us
Es
In
It
Ge
Ho
country 在我的数据框中是一个索引。 我需要做以下事情
- 如果索引值等于 'Uk' 则做某事;
- 如果索引值等于“我们”,则执行其他操作;
等等。
我已经尝试如下
if df.index.isin(['Us']) or df.isin(['Uk']):
stop_words = stopwords.words('english')
if df.index.isin(['Es']):
stop_words = stopwords.words('spanish')
但这是错误的方法。我不熟悉熊猫数据框中的索引,因为我一直使用列。 感谢您的帮助和建议。
【问题讨论】: