Read data into pandas


Provide column names while reading a dataset in pandas

# Import the required modules
import pandas as pd

Reading the dataset using read.csv() function with mentioning column names in names parameters.

#Fetching data from url as csv by mentioning values of various paramters
data = pd.read_csv("https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data",
                   header = None,
                   index_col = False,
                   names = ['sepal_length','sepal_width','petal_length','petal_width','iris_class'])

Returing the first 10 rows of the dataset using head() function

# Displaying the first ten rows of the data
data.head(n=10)
sepal_lengthsepal_widthpetal_lengthpetal_widthirsi_class
05.13.51.40.2Iris-setosa
14.93.01.40.2Iris-setosa
24.73.21.30.2Iris-setosa
34.63.11.50.2Iris-setosa
45.03.61.40.2Iris-setosa
---

Related Posts

Connect to azure datalake store using python

December 20, 2018

Read More
Connect to azure storage (blob) using python

December 22, 2018

Read More