1.head 讀取前五行數(shù)據(jù)
#隨便導(dǎo)入一些數(shù)據(jù)舉例
import pandas as pd
df = pd.read_excel('demo')
查看前五行數(shù)據(jù),對數(shù)據(jù)有初步了解
df.head()
#執(zhí)行結(jié)果如下

image.png
2.tail 讀取后五行數(shù)據(jù)
df.tail()
#執(zhí)行結(jié)果如下

image.png
3.shape 獲取數(shù)據(jù)框的行數(shù)和列數(shù)
df.shape
#執(zhí)行結(jié)果如下
#代表有15行5列

image.png
df.shape[0] #只獲取行數(shù)
df.shape[1] #只獲取列數(shù)
4.columns 獲取列名和數(shù)據(jù)類型
df.columns #獲取列名和數(shù)據(jù)類型
# 執(zhí)行結(jié)果如下

image.png
5.info 顯示數(shù)據(jù)框的簡要信息
顯示的內(nèi)容包含包括索引的數(shù)據(jù)類型dtype和列的數(shù)據(jù)類型dtype,非空值的數(shù)量和內(nèi)存使用情況
df.info()
#執(zhí)行結(jié)果如下

image.png
6.describe 生成描述性統(tǒng)計信息
描述性統(tǒng)計數(shù)據(jù):數(shù)值類型的包括均值,標(biāo)準(zhǔn)差,最大值,最小值,分位數(shù)等;類別的包括個數(shù),類別的數(shù)目,最高數(shù)量的類別及出現(xiàn)次數(shù)等;輸出將根據(jù)提供的內(nèi)容而有所不同。
df.describe()
#執(zhí)行結(jié)果如下

image.png