2

Sorry for asking to simple, on mongoDB usually the function that work is Skip, but I get lost when looking pandas equivalent. My pandas query 1st-1000th for is

list1 = a['id'].head(1000)

But, I want to query the 1001st-2000th entry , 2001st-3000th entry, etc.

I'm expected the answer to be saved as df1, df2, ... , dfn

How suppose I do this?

Nabih Bawazir
  • 5,275
  • 6
  • 29
  • 53

2 Answers2

4

You can use iloc function, and please remember that indices are zero based

a.iloc[0:1000,]
a.iloc[1000:2000,]

iloc will allow you to filter like this

Nabih Bawazir
  • 5,275
  • 6
  • 29
  • 53
loegare
  • 142
  • 1
  • 11
1

Try with // and groupby, and save your data frame into a list

l = [x for _,x in df.groupby(np.arange(len(df))//1000)]

Update

variables = locals()
for i,j in df.groupby(np.arange(len(df))//1000):
    variables["df{0}".format(i+1)] = j
BENY
  • 296,997
  • 19
  • 147
  • 204