I'm trying to create a dataframe using a csv file for a task, however every time I ran my program it would show me an error that the file could not be found. My code is the following:
import pandas as pd df = pd.read_csv('thefile')The code returns an error no matter where I put my file. When I checked the path using the following code:
import os print(os.getcwd())It showed me that the path is correct and it's looking inside the folder where my csv file is located but it still gives me the same error.
You need to add .csv behind the file,
without it, it doesn't know what file to look for, it could be the .txt file, the .conf file, the .csv file, the ...
So your code should look like this.
import pandas as pd df = pd.read_csv('thefile.csv')