johnlin
johnlin

Reputation: 11

import data in python using pandas

This is the code that I used to import my data as csv

from pandas import read_csv
from matplotlib import pyplot as pltplt
series = read_csv('final.csv', header=0, index_col=0)

this is the second one which I tried

import csv
with open('people.csv', 'r') as file:
    reader = csv.reader(file)
    for row in reader:
        print(row)

But I found same kind of error like this in both case

FileNotFoundError: [Errno 2] File final.csv does not exist: 'final.csv'

Upvotes: 1

Views: 268

Answers (2)

Maximilian Freitag
Maximilian Freitag

Reputation: 1049

You could do following:

import pandas as pd
df = pd.read_csv("./Path/where/you/stored/table/data.csv")
print(df)

(df stands for data file)

File final.csv does not exist:

The error that you make is that you don't type in the correct path where the csv is stored. Are you using jupyter?

Upvotes: 1

marouane youssfi
marouane youssfi

Reputation: 39

add the folder csv like with open('c:\\Users\\admin\\ ..... .csv', 'r') as file:

Upvotes: 0

Related Questions