Cant load data locally
-
Hello Quantiacs community,
after a break due to work I came back yesterday to the platform and am trying to load data locally but for some reason I get the following error: KeyError: "cannot represent labeled-based slice indexer for coordinate 'time' with a slice over integer positions; the index is unsorted or non-unique" (Previously I could load the data with the same formula I used : def load_data(period):
return qndata.stocks.load_ndx_data(min_date = "2002-01-01", dims = ('time', 'field', 'asset'),forward_order=True,tail = 36518)
data= load_data(36510)).
This formula works online however, does anyone know why? Thx a lot
Regards -
First of all, welcome back bro! with you over here Q20 is going to be even more challenging
I have tried your code locally (in Spyder from Anaconda):
and it manages well the code as you can see, but let me point out a couple of things that I find strange
-
When you defined the function "load_data" you established a parameter called "period" but after that you are not doing nothing with it inside de definition. So you can supress it obtaining same result:
or much better, set the parameter as the "tail" of the data:
-
The second strange thing, is that you are trying to set de parameter "min_date" and "tail" at the same time, and once you set the "min_date" let say that the "tail" doesnt do anything, taking a look inside the function that loads data inside stocks.py you can check it:
So let me suggest to drop the min_date (wich is set to None by default), like this:
...notice that the function now will load exactly what you indicates in the parameter (in my example i am loading 10 years of data) -
And the last thing is just warn you, that you are loading the "dims" as time/field/asset wich is different from the default order (field/time/asset), this can affect if you for example try to use this data with some of the provided templates by quantiacs, so be careful
I hope I've helped
Regards. -
-
@magenta-kabuto thx a lot bro for your support and pointing out the mistakes
I will try the revised code now.
Good luck for the competition