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_length sepal_width petal_length petal_width irsi_class
0 5.1 3.5 1.4 0.2 Iris-setosa
1 4.9 3.0 1.4 0.2 Iris-setosa
2 4.7 3.2 1.3 0.2 Iris-setosa
3 4.6 3.1 1.5 0.2 Iris-setosa
4 5.0 3.6 1.4 0.2 Iris-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