我需要模查询,因为数据太长,只需要显示在一个屏幕中。这是我的数据集
Name
1 they
2 ulti
3 they
4 set
5 djhd
6 tdh
7 t473
我需要的是1 modulo 3
Name
1 they
4 set
7 t473
答案 0 :(得分:2)
将boolean indexing
与模3一起使用:
df = df[df.index % 3 == 1]
print (df)
Name
1 they
4 set
7 t473
详细信息:
print (df.index % 3 )
Int64Index([1, 2, 0, 1, 2, 0, 1], dtype='int64')