Advertisement
Guest User

pandas

a guest
Oct 19th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. import pandas as pd
  2. import time
  3.  
  4. ids = [1,2,3,4,5,6,7,8,9,10,11,12]
  5. batch_size = 5
  6. df = pd.DataFrame()
  7.  
  8. def chunks(l, n):
  9.     """Yield successive n-sized chunks from l."""
  10.     for i in range(0, len(l), n):
  11.         yield l[i:i + n]
  12.  
  13. for chunk in list(chunks(ids,batchsize):
  14.     items = []
  15.     id_string = ",".join(chunk)
  16.     res = google.youtube().list(id=id_string)
  17.     for r in res:
  18.         data = {}
  19.         data['name'] = res.name
  20.         data['desc'] = res.description
  21.         items.append(data)
  22.    
  23.     df.append(items,in_place=True)
  24.     time.sleep(5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement