Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2015
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. class Security:
  2. def __init__(self):
  3. self.structure = ['timestamp', 'open', 'high', 'low', 'close', 'vol']
  4. self.df = pd.DataFrame(columns=self.structure) # index =
  5. def whats_inside(self):
  6. return self.df
  7. """
  8. Some skipped code...
  9. """
  10. def add_data(self, timestamp, open, high, low, close, vol):
  11. data = [timestamp, open, high, low, close, vol]
  12. self.df = self.df.append (data)
  13.  
  14. sec = Security()
  15. print sec.whats_inside()
  16. sec.add_data ('2015/06/01', '1', '2', '0.5', '1', '100')
  17. print sec.whats_inside()
  18.  
  19. 0 close high low open timestamp vol
  20. 0 2015/06/01 NaN NaN NaN NaN NaN NaN
  21. 1 1 NaN NaN NaN NaN NaN NaN
  22. 2 2 NaN NaN NaN NaN NaN NaN
  23. 3 0.5 NaN NaN NaN NaN NaN NaN
  24. 4 1 NaN NaN NaN NaN NaN NaN
  25. 5 100 NaN NaN NaN NaN NaN NaN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement