PythonPandas-インデックス値のリストを返します
インデックス値のリストを返すには、 index.to_list()を使用します パンダのメソッド。まず、必要なライブラリをインポートします-
import pandas as pd
パンダインデックスの作成-
index = pd.Index([50.4, 10.2, 70.5, 110.5, 90.8, 50.6])
パンダのインデックスを表示する-
print("Pandas Index...\n",index) リストを返す-
print("\nList of the index values...\n",index.to_list())
例
以下はコードです-
import pandas as pd
# Creating Pandas index
index = pd.Index([50.4, 10.2, 70.5, 110.5, 90.8, 50.6])
# 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)
# return a list
print("\nList of the index values...\n",index.to_list()) 出力
これにより、次の出力が生成されます-
Pandas Index... Float64Index([50.4, 10.2, 70.5, 110.5, 90.8, 50.6], dtype='float64') Number of elements in the index... 6 The dtype object... float64 List of the index values... [50.4, 10.2, 70.5, 110.5, 90.8, 50.6]
-
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 a
-
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()) 例 以下はコードです-