I’m going to suggest you read about what Jupyter is as part of this excellent answer here by @krassowski because I feel you have a similar issue where you are meaning to ask a Python question. (Yours is a different question though.) You’d have a better luck searching for the answer on the internet using Python
as a search term and not Jupyter
.
One way to think about, it is to ask yourself if I was running this code in a traditional Python script and not a notebook, would I have the same issue. If you’d have the same issue with your code in a script, then you have a Python question and not a Jupyter question.
That being said. I think if you ran the first two lines of this tutorial, which are:
# load
series = read_csv('monthly-car-sales.csv', header=0, index_col=0)
You found that gave an error, right? And only later in the tutorial was the rest of the code provided to make the load
step work because first from pandas import read_csv
was needed to be run.
I think something similar is going on here. Things are being shown out of order and incomplete in that line that is giving you an issue.
Somewhere along the way where the median
method is coming from got left off.
Also I am not seeing how those indices (-12, -24, -36)
would be referring to the series that was read in earlier.
In other words, it’s not you. Looks like flawed code. Take the author’s word for it and move on. The author describes what they meant to calculate pretty well. Maybe someday you’ll see something similar and be able to piece it back together correctly.
Given you seem interested in Jupyter, I’ll add that what you stumbled upon is why it is better to look for tutorials already built into Jupyter notebooks and shared that way. The ability to Run All
cells means less likely pieces will get pulled apart and posted out of order or incomplete, as it looks like that site you reference has done.