Dear all
In section 8, Unit 17 of the Python for trading: Basic course, you ask What would be the output for the below line of code?
print (df.loc [: 4, 'Close Price'])
The answer that it admits as correct is "A".
My answer has been "C", for the following reasons.
When we use .loc we are passing the name of the columns ['Close', 'Open'] which is correct, but for the index we are using the name of index 4, so it returns error:
This error means the following: "You are asking me to find the row with name 4, but such row does not exist, because your rows have date names Datetimeindex".
On the other hand, if I reproduce the sentence in my jupyter notebook, it returns the error
TypeError: cannot do slice indexing on DatetimeIndex with these indexers [4]
What is it that I do not understand or do wrong?