Pandas DataFrame Basics: Shape, Head, Unique & Sorting
Learn essential Pandas DataFrame methods like shape, head(), unique(), and sort_values() to explore and display data effectively. ๐

plus2net
1.2K views โข May 13, 2021

About this video
Use basic methods of Pandas to show the rows and columns. Details questions and sample DataFrame is here
https://www.plus2net.com/python/pandas-dataframe-exercise1.php
https://www.plus2net.com/python/pandas-student.php
using shape
print(df.shape) # ( 35, 5)
This will give number of rows and columns in the DataFrame.
Frist 4 rows of data
Print(df.head(4))
Number of rows using len()
Print(len(df))
Displaying all columns
Print(df.columns)
Displaying first 5 records and name column
Print(df[โnameโ][:5])
Displaying highest 5 records based on mark
Df=df.sort_values([โmarkโ],ascending=False)
Print(df[:5])
Displaying all unique class
print(df['class'].unique())
We can get number of unique class by using len()
#DataFramehead() #dataframebasics #dataframe #plus2net #pandas #datascience #pandastutorials
https://www.plus2net.com/python/pandas-dataframe-exercise1.php
https://www.plus2net.com/python/pandas-student.php
using shape
print(df.shape) # ( 35, 5)
This will give number of rows and columns in the DataFrame.
Frist 4 rows of data
Print(df.head(4))
Number of rows using len()
Print(len(df))
Displaying all columns
Print(df.columns)
Displaying first 5 records and name column
Print(df[โnameโ][:5])
Displaying highest 5 records based on mark
Df=df.sort_values([โmarkโ],ascending=False)
Print(df[:5])
Displaying all unique class
print(df['class'].unique())
We can get number of unique class by using len()
#DataFramehead() #dataframebasics #dataframe #plus2net #pandas #datascience #pandastutorials
Tags and Topics
Browse our collection to discover more content in these categories.
Video Information
Views
1.2K
Likes
17
Duration
4:47
Published
May 13, 2021
User Reviews
4.4
(1) Related Trending Topics
LIVE TRENDSRelated trending topics. Click any trend to explore more videos.
No specific trending topics match this video yet.
Explore All Trends