Why do you need to state and format the path here?

I am curious about the need to list the path in the loop for this lesson. If you have all of your csv files in the same folder as your workbook in jupyter, why would you need to state the path? We have never had to do this before.

If there is a reason for this, it should be stated explicitly in the lesson. This does not seem to involve a logic that we are unfamiliar with, but rather a simple fact that is hidden from students.

Screen Link: Learn data science with Python and R projects

My Code:

import pandas as pd
data_files = [
data = {}

for f in data_files:
    d = pd.read_csv('schools/{}'.format(f))
    key_name = f.replace(".csv", "")
    data[key_name] = d

Hi @Willyjgolden,

The thing is that this time all the csv files are not in the same folder as the jupyter, but they are in the folder called schools. And this schools is exactly in the same folder as the notebook. It means that we have to write this path in a for-loop to extract each file from schools. In all the previous guided projects, we had 1 or 2 csv files to work with, and they were always in the same folder as the notebook itself.

1 Like

Why does “d = pd.read_csv(‘schools/f’)” not work?