Để kiểm tra xem khoảng mở ở phía bên phải, hãy sử dụng khoảng thời gian.open_right bất động sản. Đầu tiên, hãy nhập các thư viện được yêu cầu -
import pandas as pd
Khoảng thời gian mở được đặt bằng cách sử dụng tham số "đã đóng" với giá trị "không". Khoảng mở (trong toán học được ký hiệu bằng dấu ngoặc vuông) không chứa các điểm cuối của nó, tức là khoảng mở [0, 5] được đặc trưng bởi các điều kiện 0
interval = pd.Interval(5, 20, closed='neither')
Hiển thị khoảng thời gian
print("Interval...\n",interval)
Kiểm tra xem khoảng mở ở phía bên phải hay không
print("\nCheck if the interval is open on the right side...\n",interval.open_right)
Ví dụ
Sau đây là mã
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 right side print("\nCheck if the interval is open on the right side...\n",interval.open_right)
Đầu ra
Điều này sẽ tạo ra mã sau
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 right side... True