Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 9th, 2013  |  syntax: Python  |  size: 0.23 KB  |  views: 31  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. df = pd.DataFrame(np.random.randint(0,2,100), columns=['TossResults']) # random win(0) / lose (1)
  2. df['Steps'] = (df['TossResults'].cumsum()*df['TossResults']).diff()
  3. df['Edges'] = df['Steps']<0
  4. df['Edges_Shift'] = df['Steps'].shift(1)
clone this paste RAW Paste Data