Python - 返回 Pandas 索引的最小值


要返回 Pandas 索引的最小值,请使用 index.min() 方法。首先,导入所需的库 -

import pandas as pd

创建 Pandas 索引 -

index = pd.Index([10.5, 20.4, 40.5, 25.6, 5.7, 6.8, 30.8, 50.2])

显示 Pandas 索引 -

print("Pandas Index...\n",index)

获取最小值 -

print("\nMinimum value..\n", index.min())

示例

以下为代码 -

Open Compiler
import pandas as pd # Creating Pandas index index = pd.Index([10.5, 20.4, 40.5, 25.6, 5.7, 6.8, 30.8, 50.2]) # Display the Pandas index print("Pandas Index...\n",index) # Return the number of elements in the Index print("\nNumber of elements in the index...\n",index.size) # Return the dtype of the data print("\nThe dtype object...\n",index.dtype) # get the minimum value print("\nMinimum value..\n", index.min())

输出

这将产生以下输出 -

Pandas Index...
Float64Index([10.5, 20.4, 40.5, 25.6, 5.7, 6.8, 30.8, 50.2], dtype='float64')

Number of elements in the index...
8

The dtype object...
float64

Minimum value..
5.7

更新日期:2021 年 10 月 13 日

342 次浏览

开启你的 职业生涯

完成课程即可获得认证

开始
广告