I'm a Python beginner.
I am using the pandas library in the Python 3.8.8 environment of VScode, and I am trying to read the csv file in read_csv, but I get a FileNotFoundError.
The py and test.csv files in the image are in the same directory.
I would appreciate it if you could tell me how to deal with it.
Perhaps the directory where Python is started is different from the directory where the script files are located.If the script file and the CSV file are in the same directory, you might want to do the following:
importos
import pandas aspd
csv_path=os.path.join(os.path.dirname(__file__), 'test.csv')
df = pd.read_csv(csv_path)
© 2024 OneMinuteCode. All rights reserved.