简体   繁体   中英

How do i import datasets in Python?

I try to import some datasets in my code. I need help, because I tried a lot of tutorials and web pages and I am still gettting errors. I use Spyder IDE and python 3.7 :

import numpy as np
import pandas as pd
import tensorflow as tf
import os
dts1=pd.read_csv(r"C:\Users\Cucu\Desktop\sample_submission.csv")
dts1

This works for me. If you are still experiencing errors, please post them.

import pandas as pd 
# Read data from file 'sample_submission.csv' 
# (in the same directory that your python process is based)
# Control delimiters, rows, column names with read_csv (see later) 
data = pd.read_csv(r"C:\Users\Cucu\Desktop\sample_submission.csv") 
# Preview the first 5 lines of the loaded data 
print(data.head())

Try using other approaches :

pd.read_csv("C:\\Users\\Cucu\\Desktop\\sample_submission.csv")

pd.read_csv("C:/Users/Cucu/Desktop/sample_submission.csv")

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