Python Pandas - 检查左侧的区间是否打开
要检查间隔是否在左侧打开,请使用interval.open_left属性。首先,导入所需的库-
import pandas as pd
使用值为“两者都不是”的“关闭”参数设置打开间隔。开区间(在数学中用方括号表示)不包含其端点,即开区间[0,5]的特征在于条件0<x<5
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" 带值的参数 "neither"
#Anopeninterval(inmathematicsdenotedbysquarebrackets)doesnotcontainsitsendpoints,
# i.e. the open interval [0, 5] is characterized by the conditions 0 < x < 5.
interval = pd.Interval(5, 20, closed='neither')
#displaytheinterval
print("Interval...\n",interval)
#theleftbound
print("\nThe left bound for the Interval...\n",interval.left)
#therightbound
print("\nThe right bound for the Interval...\n",interval.right)
#displaytheinterval length
print("\nInterval length...\n",interval.length)
#checkwhethertheintervalisopenontheleftside
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
热门推荐
10 八一幼儿祝福语大全简短
11 公司乔迁食堂祝福语简短
12 婚礼结束聚餐祝福语简短
13 儿媳买车妈妈祝福语简短
14 毕业送礼老师祝福语简短
15 同事辞职正常祝福语简短
16 恭贺新婚文案祝福语简短
17 金店立秋祝福语简短英文
18 婆婆高寿祝福语大全简短