Change language

Python | Pandas TimedeltaIndex.get_slice_bound

| | |

TimedeltaIndex.get_slice_bound() Pandas TimedeltaIndex.get_slice_bound() calculates the slice boundary that matches the given label ... The function returns the far left (one far right if side == & # 39; right & # 39;) position of the given label.

Syntax: TimedeltaIndex.get_slice_bound (label , side, kind)

Parameters:
label: object
side: {’ left ’,’ right ’}
kind: {’ ix ’,’ loc ’,’ getitem ’}

Return: int

Example # 1: Use TimedeltaIndex.get_slice_bound () to find the left slice boundary of the value in a given TimedeltaIndex.

# import pandas as pd

import pandas as pd

 
# Create TimedeltaIndex object

tidx = pd.TimedeltaIndex (data = [ ’3 days 06: 05: 01.000030’ , ’ 1 days 06: 05: 01.000030’ ,

’3 days 06: 05: 01.000030’ , ’ 1 days 02: 00: 00’ ,

’21 days 06: 15: 01.000030’ ])

 
# Print TimedeltaIndex object

print (tidx)

Output:

Now we will use Use TimedeltaIndex.get_slice_bound () to find the left slice boundary & # 39; 1 days 02: 00: 00 & # 39 ;.

# find the left slice bound to the passed value

tidx.get_slice_bound ( ’1 days 02: 00: 00’ , side = ’left’ , kind = ’loc’ )

Output:

As we can see in the output, TimedeltaIndex.get_slice_bound () returned 3 as slice boundaries for the passed value in this TimedeltaIndex object.

Example # 2: Use Call TimedeltaIndex.get_slice_bound () to find the left slice boundary of the value in this TimedeltaIndex.

# import pandas as pd

import pandas as pd

 
# Create TimedeltaIndex object

tidx = pd.TimedeltaIndex (data = [ ’06: 05: 01.000030’ , ’ 3 days 06: 05: 01.000030 ’

  ’ 22 day 2 min 3us 10ns’ , ’+23: 59: 59.999999’ ,

’13 days 06: 05: 01.000030’ , ’+12: 19: 59.999999’ ])

 
# Print TimedeltaIndex object

print (tidx)

Output:

Now we will use TimedeltaIndex.get_slice_bound () to find the border of the left slice "13 days 06: 05: 01.000030".

# find the left slice anchored to passed value

tidx.get_slice_bound ( ’13 days 06: 05: 01.000 030’ , side = ’left’ , kind = ’loc’ )

Output:

As we can see in the output, TimedeltaIndex.get_slice_bound () returned 4 as the slice boundary for the passed value in the given TimedeltaIndex.

Shop

Learn programming in R: courses

$

Best Python online courses for 2022

$

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

Latest questions

NUMPYNUMPY

Common xlabel/ylabel for matplotlib subplots

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

12 answers

NUMPYNUMPY

Flake8: Ignore specific warning for entire file

12 answers

NUMPYNUMPY

glob exclude pattern

12 answers

NUMPYNUMPY

How to avoid HTTP error 429 (Too Many Requests) python

12 answers

NUMPYNUMPY

Python CSV error: line contains NULL byte

12 answers

NUMPYNUMPY

csv.Error: iterator should return strings, not bytes

12 answers

News


Wiki

Python | How to copy data from one Excel sheet to another

Common xlabel/ylabel for matplotlib subplots

Check if one list is a subset of another in Python

sin

How to specify multiple return types using type-hints

exp

Printing words vertically in Python

exp

Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries

cos

Python add suffix / add prefix to strings in a list

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

Python - Move item to the end of the list

Python - Print list vertically