PythonPandas-左側で間隔が開いているかどうかを確認します
左側で間隔が開いているかどうかを確認するには、 interval.open_leftを使用します 財産。まず、必要なライブラリをインポートします-
import pandas as pd
値が「どちらでもない」の「closed」パラメーターを使用して設定されたオープン間隔。開区間(角括弧で示される数学)にはその端点が含まれていません。つまり、開区間[0、5]は条件0
interval = pd.Interval(5, 20, closed='neither')
間隔を表示する
print("Interval...\n",interval)
左側でインターバルが開いているかどうかを確認します
print("\nCheck if the interval is open on the left side...\n",interval.open_left)
例
以下はコードです
import pandas as pd # Open interval set using the "closed" parameter with value "neither" # An open interval (in mathematics denoted by square brackets) does not contains its endpoints, # i.e. the open interval [0, 5] is characterized by the conditions 0 < x < 5. interval = pd.Interval(5, 20, closed='neither') # display the interval print("Interval...\n",interval) # the left bound print("\nThe left bound for the Interval...\n",interval.left) # the right bound print("\nThe right bound for the Interval...\n",interval.right) # display the interval length print("\nInterval length...\n",interval.length) # check whether the interval is open on the left side print("\nCheck if the interval is open on the left side...\n",interval.open_left)>
出力
これにより、次のコードが生成されます
Interval... (5, 20) The left bound for the Interval... 5 The right bound for the Interval... 20 Interval length... 15 Check if the interval is open on the left side... True
-
Python-PandasIndexがフローティングタイプかどうかを確認します
Pandas Indexがフローティングタイプであるかどうかを確認するには、 index.is_floating()を使用します パンダのメソッド。まず、必要なライブラリをインポートします- import pandas as pd パンダインデックスの作成- index = pd.Index([5.7, 6.8, 10.5, 20.4, 25.6, 30.8, 40.5, 50.2]) パンダのインデックスを表示する- print("Pandas Index...\n",index) インデックス値に浮動小数点数しかないかどうかを確認します- print("
-
pythonPandas-IntervalArrayの各間隔の左端をインデックスとして返します
IntervalArrayの各間隔の左端をインデックスとして返すには、 array.leftを使用します プロパティ。 まず、必要なライブラリをインポートします- import pandas as pd 2つのIntervalオブジェクトを作成します- nterval1 = pd.Interval(10, 25) interval2 = pd.Interval(15, 70) 間隔を表示する- print("Interval1...\n",interval1) print("Interval2...\n",interval2) Intervalオ