top of page
learn_data_science.jpg

Data Scientist Program

 

Free Online Data Science Training for Complete Beginners.
 


No prior coding knowledge required!

Head and Tail of DataFrame in Pandas

Writer: Arpan SapkotaArpan Sapkota


To view a small sample of a Series or DataFrame object, use the head() and tail() methods. The default number of elements to display is five, but you may pass a custom number.

head() returns the first n rows(observe the index values). The default number of elements to display is five, but you may pass a custom number.


tail() returns the last n rows(observe the index values). The default number of elements to display is five, but you may pass a custom number.

Lets start with importing the pandas and numpy

import pandas as pd
import numpy as np

Create a series with random numbers

long_series = pd.Series(np.random.randn(1000))

The first five rows of the data series:

long_series.head()

Output:

0    0.580156
1    0.469914
2   -0.744791
3   -2.381032
4    0.954909

The last three rows of the data series:

long_series.tail(3)

997    0.294750
998   -1.108673
999    0.013724
 
 

Comments


COURSES, PROGRAMS & CERTIFICATIONS

 

Advanced Business Analytics Specialization

Applied Data Science with Python (University of Michigan)

Data Analyst Professional Certificate (IBM)

Data Science Professional Certificate (IBM)

Data Science Specialization (John Hopkins University)

Data Science with Python Certification Training 

Data Scientist Career Path

Data Scientist Nano Degree Program

Data Scientist Program

Deep Learning Specialization

Machine Learning Course (Andrew Ng @ Stanford)

Machine Learning, Data Science and Deep Learning

Machine Learning Specialization (University of Washington)

Master Python for Data Science

Mathematics for Machine Learning (Imperial College London)

Programming with Python

Python for Everybody Specialization (University of Michigan)

Python Machine Learning Certification Training

Reinforcement Learning Specialization (University of Alberta)

Join our mailing list

Data Insight participates in affiliate programs and may sometimes get a commission through purchases made through our links without any additional cost to our visitors.

bottom of page