code:
import pandas as pd
file_path='./read_csv_sample.csv'
df1=pd.read_csv(file_path)
print(df1)
df2=pd.read_csv(file_path,header=None)
print(df2)
df3=pd.read_csv(file_path,index_col=None)
print(df3)
df4=pd.read_csv(file_path,index_col='c0')
print(df4)
error:
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
<ipython-input-11-4a42e39c37ec> in <module>
2 file_path='./read_csv_sample.csv'
3
----> 4 df1=pd.read_csv(file_path)
5 print(df1)
6 df2=pd.read_csv(file_path,head=None)
7 frames
/usr/local/lib/python3.8/dist-packages/pandas/io/common.py in get_handle(path_or_buf, mode, encoding, compression, memory_map, is_text, errors, storage_options)
700 if ioargs.encoding and "b" not in ioargs.mode:
701 # Encoding
--> 702 handle = open(
703 handle,
704 ioargs.mode,
FileNotFoundError: [Errno 2] No such file or directory: './read_csv_sample.csv'
I already downloaded read_csv_sample.csv file at Wallpapers(desktop) but it doesn't work 2nd and 4th line. the error formed.