简体   繁体   中英

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'

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?

添加文件夹 csv 就像with open('c:\\\\Users\\\\admin\\\\ ..... .csv', 'r') as file:

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