新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
創(chuàng)新互聯(lián)Python教程:pandas中index索引功能是什么
pandas的索引對(duì)象可以用來保存坐標(biāo)軸標(biāo)簽和其它元數(shù)據(jù),是使用過程中必要的參與對(duì)象,那pandas中index索引功能是什么呢?pandas中index索引可以輕松的讀取數(shù)據(jù),更方便的數(shù)據(jù)查詢,使用index查詢的時(shí)候可以獲得性能提升。

一、index索引特點(diǎn)
更方便的數(shù)據(jù)查詢,使用index查詢的時(shí)候可以獲得性能提升;
自動(dòng)的數(shù)據(jù)對(duì)齊功能;
更多更強(qiáng)大的數(shù)據(jù)結(jié)構(gòu)支持。
二、index索引用途
1、使用index讀取數(shù)據(jù)
import pandas as pd
df = pd.read_csv("./datas/ml-latest-small/ratings.csv")
df.count()#記錄每一列的數(shù)目2、使用index查詢數(shù)據(jù)
# drop==False,讓索引列還保持在column
df.set_index("userId", inplace=True, drop=False)
df.head()
df.index
Int64Index([ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
...
610, 610, 610, 610, 610, 610, 610, 610, 610, 610],
dtype='int64', name='userId', length=100836)
# 使用index的查詢方法
df.loc[500].head(5)以上就是pandas中index索引的相關(guān)介紹,希望能幫助你理解喲~更多python學(xué)習(xí)推薦:python教程。
(推薦操作系統(tǒng):windows7系統(tǒng)、Python 3.9.1,DELL G3電腦。)
分享題目:創(chuàng)新互聯(lián)Python教程:pandas中index索引功能是什么
本文路徑:http://www.dlmjj.cn/article/cdijgdc.html


咨詢
建站咨詢
