Please read Getting good answers to your questions. I’d also suggest especially reading in the link to How do I ask a good question? at the bottom there. Your post from the get-go lacked information you had and could have shared. (And could have shared as text, preferably. Or screenshot along the text at the very least. Make things easy for those trying to help you.)
Two points in that post address exactly what you see:
“3. If
filepath
variable stores a URL address it will not work directly with **pandas.read_csv()` method here - this environment does not supper such usage (see #2). pandas.read_csv() can only e used to read stored CSV fiile (i.e. downloaded via a different method, see #2 again)”
“However, in this version of the lab, which operates on JupyterLite, the dataset needs to be downloaded to the interface using the provided code below.”
JupyterLite running on the coursera site cannot use a URL supplied to pandas.read_csv()
. It is stated clearly in both those quoted statements. And you even found that to be the case when you tried it.
Good for you for trying it and confirming. However, what did you try differently after being told that wouldn’t work, and experiencing it for yourself?
We keep going in circles because how to do it is spelled out in that post and I provided a more straightforward way that doesn’t involve writing code. Importantly, I, and the other person trying to help you in the screenshot, both think you may have done the download step the code way and then didn’t use it? This is why the person in the post in the screenshot is exasperated a bit. I just looked in the .ipynb
you provided and it seems you may have downloaded the file from the URL and renamed it auto.csv
So your code should be after running the ‘download’ cell:
import pandas as pd
df = pd.read_csv("auto.csv")
Or if you want to do it the ‘foolproof’ way I describe, where you download the file first to your own local machine and then drag and drop it in the file browser in the directory next to your running notebook, then you’d still use the file name of auto.csv
. Of course, they may have disabled drag-and-drop in the Coursera JupyterLite. I don’t have access to test if they somehow blocked the ‘foolproof’ way. That shouldn’t matter because it looked like the ‘download’ cell worked in the first screenshot you provided. So after running that sell run the code I’ve urged you to run twice now, df = pd.read_csv("auto.csv")
, and Pandas will read the data from where it is stored in the virtual filesystem running in your browser after auto.csv
was downloaded via that code that reads await download(file_path, "auto.csv")
. )
Note that in the screenshot you originally provided, the file auto.csv
is shown listed in the same directory with your notebook. So just read the data in now with df = pd.read_csv("auto.csv")
.
That way, when you run the next cell in your notebook, which is the code cell below, it will work now and show the first five rows of the dataframe:
# show the first 5 rows using dataframe.head() method
print("The first 5 rows of the dataframe")
df.head(5)