Python: 如何判断一个变量的后三位是否为000?

Python: How do I check if the last three number of a variable to be 000 or not?

结合 excel,我正在寻找一种解决方案,通过实施 if 语句来检查公司代码是否以 000 结尾(任何其他)。输出应该是 True 或 False 语句。我不知道如何开始。想过用switches,但是不知道switches之后怎么实现功能或者action。

例如: Excel Chart

示例: 如果代码以 000 结尾:true 如果代码以 001 结尾:false

使用Series.str.endswith测试一些列,这里column:

#if necessary convert file to DataFrame
df = pd.read_excel(file)

df['test'] = df['column'].str.endswith('000')