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

一、index索引特點
更方便的數(shù)據(jù)查詢,使用index查詢的時候可以獲得性能提升;
自動的數(shù)據(jù)對齊功能;
更多更強大的數(shù)據(jù)結構支持。
二、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索引的相關介紹,希望能幫助你理解喲~更多python學習推薦:python教程。
(推薦操作系統(tǒng):windows7系統(tǒng)、Python 3.9.1,DELL G3電腦。)
網頁標題:創(chuàng)新互聯(lián)Python教程:pandas中index索引功能是什么
轉載來源:http://www.5511xx.com/article/cdijgdc.html


咨詢
建站咨詢
