如何对熊猫进行模查询

时间:2018-06-29 07:34:01

标签: pandas dataframe timestamp boolean booleanquery

我需要模查询,因为数据太长,只需要显示在一个屏幕中。这是我的数据集

     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

1 个答案:

答案 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')