简体   繁体   中英

How to fix FileNotFoundError: [Errno 2] No such file or directory: no

I am trying to open a file from my local disk in Jupter. I used to see the output but since a couple of days ago it brings the file not found error. I can still see the file on the path provided above. any help? thanks

import numpy as np
import pandas as pd
from pandas import DataFrame 
import scipy.stats as stats
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline

adf=pd.read_csv('C:/Users/New folder/churn.csv')
adf.head()

尝试这个:

adf=pd.read_csv('C:\\Users\\New folder\\churn.csv')

The path you are using is more UNIX based, on Windows, you need to use double backslashes.

C:\\Location\\file_is_here.csv

There is another way around it, consists of using pathlib

from pathlib import Path
your_file_path = Path().joinpath('C', 'Location', 'file_is_here.csv')

This will take care of slashes for you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM