Issue
I'm beginner in Python, I'm doing a lab in Jupyter notebook, the instructor in the video is using Anaconda, while I use simply Jupyter notebook. In the beginning of the lab he is copying the path to the csv file and introducing the path to Anaconda terminal to upload the csv file to Jupyter notebook. But as I don't have Anaconda, I tried to simply upload csv file manually to Jupiter notebook. However, with that done the code below doesn't work:
import numpy as np
import pickle
import pandas as pd
filename = "load.csv"
with open(filename) as f:
for line in f.readlines():
vals = line.replace("\n", "").split(",")
if cols is None:
cols = vals
else:
data.append([float(x) for x in vals])
What should I do for the code to work?
Solution
I would do the following:
import pandas as pd
filename = "load.csv"
dataframe = pd.read_csv(filename)
Make sure the file load.csv
is located in the same folder as your python notebook.
Answered By - Guilherme Rodrigues
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.