In doing the Calculate Futures PnL python section I am having a difficult time inside of Quantra. I had a difficult time reading the csv file so I just copied it and put it directly in C:<br />
When I run the following line of code in Jupyter I a have no problem:
price_data_gold = pd.read_csv('C:\GC22020M.csv', index_col=0, parse_dates=True)
When I run the same path in the quantra website I keep getting errors;
n error occured while running the code:
At line: 5, in price_data_gold = price_data_gold = pd.read_csv('C:\GC22020M.csv', index_col=0) File "/home/app/.local/lib/python3.6/site-packages/pandas/io/parsers.py", line 678, in parser_f return _read(filepath_or_buffer, kwds) File "/home/app/.local/lib/python3.6/site-packages/pandas/io/parsers.py", line 440, in _read parser = TextFileReader(filepath_or_buffer, **kwds) File "/home/app/.local/lib/python3.6/site-packages/pandas/io/parsers.py", line 787, in __init__ self._make_engine(self.engine) File "/home/app/.local/lib/python3.6/site-packages/pandas/io/parsers.py", line 1014, in _make_engine self._engine = CParserWrapper(self.f, **self.options) File "/home/app/.local/lib/python3.6/site-packages/pandas/io/parsers.py", line 1708, in __init__ self._reader = parsers.TextReader(src, **kwds) File "pandas/_libs/parsers.pyx", line 384, in pandas._libs.parsers.TextReader.__cinit__ File "pandas/_libs/parsers.pyx", line 695, in pandas._libs.parsers.TextReader._setup_parser_source
FileNotFoundError: File b'C:\\GC22020M.csv' does not exist
Hi Rick,
On Quantra, the data file is stored in the directory data_modules. So you need to pass the data_modules as a path to read CSV files. If you pass a path other than data_modules, you will get an error "File does not exist".
All the codes and data files are available used in this course are available in the downloadable unit of the last section of this course. Once you download the files, you can run the notebooks without changing the directory.
Hope this helps. Thanks!
I have tried everything in the shell that comes with the course and no luck at all. I have moved files (csv) and changed "/" to "" and back again several times. In Anacaonda the following line works (others with the data_modules directory do not):
price_data_gold = pd.read_csv('c:\GC22020M.csv', index_col=0, parse_dates=True)
The same exact line in the Quantra shell does not work and comes back with file does not exist.
When I put the following line in either the shell or Anaconda I get a syntax error:
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 12-13: truncated \UXXXXXXXX escape
here is the code:
price_data_gold = pd.read_csv('?C:\Users\Trader\Documents\data_modules\GC22020M.csv', index_col=0, parse_dates=True)
If I change the "" to "/" like the python file Calculate Futures PnL (comes with the course), I get the OSError [Errno 22] invalis argument
Hi Rick,
price_data_gold = pd.read_csv('c:\GC22020M.csv', index_col=0, parse_dates=True)
This line of code doesn't work on Quantra because there is no directory 'c' on Quantra.
To make this work, you need to use the below line of code.
price_data_gold = pd.read_csv('…/data_modules/GC22020M.csv', index_col=0, parse_dates=True)
In this case, the GC22020M.csv file is saved inside the data_modules folder. Similarly, to make it work on your local system, you need to check both the csv file and notebook path.
Another more straightforward thing you can do is download all Notebooks and data files from the last unit of the course. After downloading, unzip the folder. Next, open the Jupyter notebook, go to the same path where you have unzipped the folder. And run notebook directly from there only.
If this doesn't work, feel free to write us at quantra@quantinsit.com. We can resolve this issue on call.
Thanks!
I can run the file in Jupyter notebook no problem with the path. It is the shell within the course that I cannot get it to run. So taking the course is impossible without being able to load the file.
Hi Rick,
Really sorry you haven't been able to progress past this.
I believe you are trying to attempt the coding exercise, Section 5 Unit 7. The line you mentioned runs on your system because you must have stored the file in the C drive. However, Quantra does not have a directory by this name. We have created a directory by the name 'data_modules' that has the file. Hence on Quantra, you have to use '…/data_modules/GC22020M.csv' as the file path.
The below line should help you submit the exercise successfully.
price_data_gold = pd.read_csv('…/data_modules/GC22020M.csv', index_col=0)
Please note that the path is also case sensitive.
Attaching a screenshot for your reference.
Also, on the bottom left you would be able to see the hints/solution for your reference.
Doing this, you should be able to submit the task. If not, please share a screenshot of the task (along with the Section and the Unit number) so that we can look into it.
Hope this helps you.