---> 84 filepath = Path(__file__) # this not part of course, got tip from friend
85 data = {
86 "W": Path(f"{filepath.parent}/washington.csv"),
87 "C": Path(f"{filepath.parent}/chicago.csv"),
88 "N": Path(f"{filepath.parent}/new_york_city.csv"),
89 }
91 df = pd.read_csv(data[city].as_posix())
NameError: name '__file__' is not defined
I get this name error in Jupyter but it works fine in VSCode and PyCharm. The files are in the same directory as the script file. How do I resolve it?
Googled pathlib error in Jupyter and come across a stack about that there is another way than pathlib. eg os.path. Anyone knows how to use this to solve my issue?