How to upload data file on Jupyter for Data Science Project

0

Hi Everyone, I am trying to learn python and data science on my own. It’s a career change. I took a free class on ‘FreeCodeCamp.org/youtube channel’ I am trying to practice a project the instructor has an example. Instructor is able to upload the data to jupyter. However I am typing EXACT SAME CODE that the instructor has but there is nothing happing on my end. It just comes as a new line without any error or answer either. I have saved the data file sales_data.csv on my desktop and on Jupyter, For example:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
sales=pd.read_csv(sales_data.csv)

I am getting following error: ---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Input In [2], in ()
----> 1 sales=pd.read_csv(sales_data.csv)

NameError: name ‘pd’ is not defined

What am I doing wrong? What needs to be done for it to work?

import pandas as pd at the start of your code should work.

Are you absolutely sure that you already have that line in your code?

1 Like

By Anisha Muni via Discussions on Python.org at 07Jul2022 21:45:

Hi Everyone, I am trying to learn python and data science on my own.
It’s a career change. I took a free class on ‘FreeCodeCamp.org/youtube
channel’ I am trying to practice a project the instructor has an
example. Instructor is able to upload the data to jupyter. However I am
typing EXACT SAME CODE that the instructor has but there is nothing
happing on my end. […]

Just a nitpick. You say:

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
sales=pd.read_csv(sales_data.csv)

and getting:

NameError Traceback (most recent call last)
Input In [2], in ()
----> 1 sales=pd.read_csv(sales_data.csv)
NameError: name 'pd' is not defined

Steven has mentioned that this implies that the pandas import didn’t
work, or isn’t in the snippet your actually trying.

But also, after that is solved, you have this code:

sales=pd.read_csv(sales_data.csv)

which will try to access the .csv attribute of some variable named
sales_data. I expect that is actually a filename, so you want to write
this:

sales=pd.read_csv("sales_data.csv")

which supplies the filename as a string "sales_data.csv".

Cheers,
Cameron Simpson cs@cskk.id.au