Sunday, 24 September 2017

How to read CSV files using pandas module ?


USE pandas FOR READING CSV FILE

EXAMPLE
import pandas as pd

# Sample CSV data
# 5.1,0.222222222,3.5,0.625,setosa
# 4.9,0.166666667,3,0.416666667,setosa
 

data = pd.read_csv('myData.csv',
                   names = ["SepalLength", "SepalWidth", "PetalLength", "PetalWidth", "Class"])


# Takes first 5 rows
print(data.head())


# Print the data dimension : rows and cols
print(data.shape)

No comments:

Post a Comment

Note: only a member of this blog may post a comment.