Created
October 10, 2014 06:49
-
-
Save xccds/791a100189486459d478 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#原始的方式 | |
lines = [line.split(',') for line in open('iris.csv')] | |
df = [[float(x) for x in line[:4]] for line in lines[1:]] | |
#使用numpy包 | |
import numpy as np | |
lines = np.loadtxt('iris.csv',delimiter=',',dtype='str') | |
df = lines[1:,:4].astype('float') | |
#使用pandas包 | |
import pandas as pd | |
df = pd.read_csv('iris.csv') | |
df=df.ix[:,:4] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment