SHARE
TWEET

Untitled

a guest Jun 16th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from itertools import zip_longest
  2. import itertools
  3. import pandas
  4. import numpy as np
  5. import matplotlib.pyplot as plt
  6.  
  7. all_trades = pandas.read_csv('./ccmx18hf .csv', parse_dates={'Date': [0,1]}, index_col=0, encoding = 'unicode_escape')
  8. print (all_trades.head())
  9.  
  10.  
  11. volume = (all_trades['quant_total'])
  12. print(volume.head())
  13. trades = (all_trades['preco_ordem'])
  14.  
  15. def cleanup(x):
  16.     if isinstance(x, str) and 'e-' in x:
  17.         return 0
  18.     else:
  19.         return float(x)
  20.  
  21. volume = volume.apply(lambda x: cleanup(x))
  22. volume = volume.astype(np.float32)
  23.      
  24. order_side preÂ�o_ordem  quant_total  quant_neg status
  25. Date                                                                    
  26. 02/07/2018 08:58:25   Sell       39,36            4        0.0   New
  27. 02/07/2018 08:59:53   Sell          40            1        0.0   New
  28. 02/07/2018 08:59:56   Sell       39,93            1        0.0   New
  29. 02/07/2018 09:00:22    Buy        39,1           10        0.0   New
  30. 02/07/2018 09:00:26    Buy       39,11            1        0.0   New
  31. Date
  32. 02/07/2018 08:58:25     4
  33. 02/07/2018 08:59:53     1
  34. 02/07/2018 08:59:56     1
  35. 02/07/2018 09:00:22    10
  36. 02/07/2018 09:00:26     1
  37. Name: quant_total, dtype: int64
  38.      
  39. Traceback (most recent call last):
  40.   File "/home/operacao/miniconda2/envs/py3env/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 2657, in get_loc
  41.     return self._engine.get_loc(key)
  42.   File "pandas/_libs/index.pyx", line 108, in pandas._libs.index.IndexEngine.get_loc
  43.   File "pandas/_libs/index.pyx", line 132, in pandas._libs.index.IndexEngine.get_loc
  44.   File "pandas/_libs/hashtable_class_helper.pxi", line 1601, in pandas._libs.hashtable.PyObjectHashTable.get_item
  45.   File "pandas/_libs/hashtable_class_helper.pxi", line 1608, in pandas._libs.hashtable.PyObjectHashTable.get_item
  46. KeyError: 'preco_ordem'
  47.  
  48. During handling of the above exception, another exception occurred:
  49.  
  50. Traceback (most recent call last):
  51.   File "ccmx.py", line 15, in <module>
  52.     trades = (all_trades['preco_ordem'])
  53.   File "/home/operacao/miniconda2/envs/py3env/lib/python3.7/site-packages/pandas/core/frame.py", line 2927, in __getitem__
  54.     indexer = self.columns.get_loc(key)
  55.   File "/home/operacao/miniconda2/envs/py3env/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 2659, in get_loc
  56.     return self._engine.get_loc(self._maybe_cast_indexer(key))
  57.   File "pandas/_libs/index.pyx", line 108, in pandas._libs.index.IndexEngine.get_loc
  58.   File "pandas/_libs/index.pyx", line 132, in pandas._libs.index.IndexEngine.get_loc
  59.   File "pandas/_libs/hashtable_class_helper.pxi", line 1601, in pandas._libs.hashtable.PyObjectHashTable.get_item
  60.   File "pandas/_libs/hashtable_class_helper.pxi", line 1608, in pandas._libs.hashtable.PyObjectHashTable.get_item
  61. KeyError: 'preco_ordem'
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top