Pandas數(shù)據(jù)形狀df.shape的實現(xiàn)
pandas: shape()獲取Dataframe的行數(shù)和列數(shù)
返回列數(shù):
df.shape[1]
返回行數(shù):
df.shape[0] 或者:len(df)
返回形狀,即幾行幾列的數(shù)組
dataframe.shape()
執(zhí)行df.shape會返回一個元組,該元組的第一個元素代表行數(shù),第二個元素代表列數(shù),這就是這個數(shù)據(jù)的基本形狀,也是數(shù)據(jù)的大小
import pandas as pd df = pd.DataFrame([['liver','E',89,21,24,64], ['Arry','C',36,37,37,57], ['Ack','A',57,60,18,84], ['Eorge','C',93,96,71,78], ['Oah','D',65,49,61,86] ], columns = ['name','team','Q1','Q2','Q3','Q4']) df.shape # (5, 6) # 共5行6列(索引不算) df.shape[0] # 5 df.shape[1] # 6 # Series只有一個值 s = pd.Series(['One','Two','Three']) s.shape # (3,) s.shape[0] # 3
結(jié)果展示
df
s
到此這篇關(guān)于Pandas數(shù)據(jù)形狀df.shape的實現(xiàn)的文章就介紹到這了,更多相關(guān)Pandas df.shape內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
python接口調(diào)用已訓(xùn)練好的caffe模型測試分類方法
今天小編就為大家分享一篇python接口調(diào)用已訓(xùn)練好的caffe模型測試分類方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-08-08python實現(xiàn)查找excel里某一列重復(fù)數(shù)據(jù)并且剔除后打印的方法
這篇文章主要介紹了python實現(xiàn)查找excel里某一列重復(fù)數(shù)據(jù)并且剔除后打印的方法,涉及Python使用xlrd模塊操作Excel的相關(guān)技巧,需要的朋友可以參考下2015-05-05