简体   繁体   中英

Cannot import csv file in online Jupyter notebook

I have tried with all the existing combinations

Tried the below code.

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import os
os.getcwd()
os.chdir(r'C:\Users\mgs2374\Desktop')
df=pd.read_csv("CarPrice_Assignment.csv")

where i'm trying to import a file using an online jupyter notebook.

If I give 'r' in os.chdir(r'C:\Users\mgs2374\Desktop') it says no Module named seaborn. If I comment import seaborn statement,it shows file not found error. FileNotFoundError Traceback (most recent call last) in 5 import os 6 os.getcwd() ----> 7 os.chdir(r'C:\Users\mgs2374\Desktop') 8 df=pd.read_csv("CarPrice_Assignment.csv") 9 FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\mgs2374\Desktop'

1:)

it says no Module named seaborn

You need to install seaborn before you can use it

If you use pip:

pip install seaborn

Or conda:

conda install seaborn

2:)

If I comment import seaborn statement,it shows file not found error.

Simply change

os.getcwd()
os.chdir(r'C:\Users\mgs2374\Desktop')
df=pd.read_csv("CarPrice_Assignment.csv")

to

 df=pd.read_csv(r'C:\Users\mgs2374\Desktop\CarPrice_Assignment.csv')

If you copy the path ( C:\Users\mgs2374\Desktop\CarPrice_Assignment.csv ) into your explorer the csv file should be opened. If it doesn't, your path is wrong.

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