Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Security:
- def __init__(self):
- self.structure = ['timestamp', 'open', 'high', 'low', 'close', 'vol']
- self.df = pd.DataFrame(columns=self.structure) # index =
- def whats_inside(self):
- return self.df
- """
- Some skipped code...
- """
- def add_data(self, timestamp, open, high, low, close, vol):
- data = [timestamp, open, high, low, close, vol]
- self.df = self.df.append (data)
- sec = Security()
- print sec.whats_inside()
- sec.add_data ('2015/06/01', '1', '2', '0.5', '1', '100')
- print sec.whats_inside()
- 0 close high low open timestamp vol
- 0 2015/06/01 NaN NaN NaN NaN NaN NaN
- 1 1 NaN NaN NaN NaN NaN NaN
- 2 2 NaN NaN NaN NaN NaN NaN
- 3 0.5 NaN NaN NaN NaN NaN NaN
- 4 1 NaN NaN NaN NaN NaN NaN
- 5 100 NaN NaN NaN NaN NaN NaN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement