
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get the Left Bound for the Interval in Python Pandas
To get the left bound for the interval, use the interval.left property. At first, import the required libraries −
import pandas as pd
Use Timestamps as the bounds to create a time interval. Closed interval set using the "closed" parameter with value "left". Get the left bound for the interval
interval = pd.Interval(pd.Timestamp('2020-01-01 00:00:00'), pd.Timestamp('2021-01-01 00:00:00'), closed='left')
Display the interval
print("Interval...\n",interval)
Get the left bound
print("\nThe left bound for the Interval...\n",interval.left)
Example
Following is the code
import pandas as pd # Use Timestamps as the bounds to create a time interval # Closed interval set using the "closed" parameter with value "left" # Get the left bound for the interval interval = pd.Interval(pd.Timestamp('2020-01-01 00:00:00'), pd.Timestamp('2021-01-01 00:00:00'), closed='left') # display the interval print("Interval...\n",interval) # display the interval length print("\nInterval length...\n",interval.length) # the left bound print("\nThe left bound for the Interval...\n",interval.left)
Output
This will produce the following code
Interval... [2020-01-01, 2021-01-01) Interval length... 366 days 00:00:00 The left bound for the Interval... 2020-01-01 00:00:00
Advertisements