我有一个数据帧:
index assets
1 12345
2 54343
3 39483000
4 2543553
5 22425000
6 5342334345
7 244224000
我想显示以"000"结尾的值。
Df
index assets
3 39483000
5 22425000
7 244224000
您可以使用pd.Series.astype(str)
将assets
转换为str
后使用pd.Series.str.endswith
并使用boolean indexing
。
df[df.assets.astype(str).str.endswith('000')]
index assets
2 3 39483000
4 5 22425000
6 7 244224000
或
pd.Series.mod
pd.Series.eq
和使用boolean indexing
df[df.assets.mod(1000).eq(0)]
index assets
2 3 39483000
4 5 22425000
6 7 244224000