Python-Pandasインデックスの最大値を返します
パンダインデックスの最大値を返すには、 index.max()を使用します 方法。まず、必要なライブラリをインポートします-
import pandas as pd
パンダインデックスの作成
index = pd.Index([10, 20, 70, 40, 90, 50, 25, 30])
パンダのインデックスを表示する-
print("Pandas Index...\n",index) 最大値を取得-
print("\nMaximum value..\n", index.max())
例
以下はコードです-
import pandas as pd
# Creating Pandas index
index = pd.Index([10, 20, 70, 40, 90, 50, 25, 30])
# 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 maximum value
print("\nMaximum value..\n", index.max()) 出力
これにより、次の出力が生成されます-
Pandas Index... Int64Index([10, 20, 70, 40, 90, 50, 25, 30], dtype='int64') Number of elements in the index... 8 The dtype object... int64 Maximum value.. 90
-
Python-Pandasインデックスの最小値を返します
パンダインデックスの最小値を返すには、 index.min()を使用します 方法。まず、必要なライブラリをインポートします- import pandas as pd パンダインデックスの作成- index = pd.Index([10.5, 20.4, 40.5, 25.6, 5.7, 6.8, 30.8, 50.2]) パンダのインデックスを表示する- print("Pandas Index...\n",index) 最小値を取得- print("\nMinimum value..\n", index.min()) 例 以下はコードです-
-
PythonPandas-Timedeltaオブジェクトの最大値を返します
Timedeltaオブジェクトの最大値を返すには、 timedelta.max 財産。まず、必要なライブラリをインポートします- import pandas as pd Timedeltaオブジェクトを作成する timedelta = pd.Timedelta('5 days 1 min 45 s 40 ns') 最大値を返す timedelta.max 例 以下はコードです import pandas as pd # TimeDeltas is Python’s standard datetime library uses a different r