蟒蛇 | Pandas tseries.offsets.BusinessHour.kwds

可以創建 DateOffsets 以將日期移動指定數量的有效日期。例如, Bday (2) 可以添加到日期以將其向前移動兩個工作日。如果日期不是以有效日期開始的,則首先將其移至有效日期,然後生成偏移量。

tseries.offsets.BusinessHour.kwds pandas tseries.offsets.BusinessHour.kwds 返回應用於給定偏移對象的關鍵字參數。

語法: pandas.tseries.offsets.BusinessHour.kwds

參數:

< p> 返回: kwds

示例#1: 使用 pandas.tseries.offsets.BusinessHour.kwds 屬性返回應用於給定偏移量的關鍵字參數。

# import pandas as pd

import pandas as pd


# 創建時間戳

ts = pd.Timestamp ( ’2019-10-10 11: 15:00’ )


# 創建偏移量

bh = pd.tseries.offsets.BusinessHour (n = 5 )


# 打印時間戳

print (ts)


#打印偏移量

print (bh)

輸出:

現在我們將在這個時間戳對像中添加一個營業時間偏移量增加日期時間值。我們還將打印出應用於給定偏移量的參數關鍵字。

# 給指定時間戳添加營業時間偏移

new_timestamp = ts + bh

< p>
# 打印更新的時間戳

print (new_timestamp)


# 打印關鍵字參數
# 適用於給定的偏移量

print (bh.kwds)

輸出:

< img src = "http://espressocode.top/images/malraveabbackgeacer280795.jpg "/>

正如我們在輸出中看到的那樣,我們已經成功創建了一個偏移量並將其添加到給定的時間戳中。我們還打印了應用於給定偏移量的關鍵字參數。

示例 #2: 使用 pandas.tseries.offsets.BusinessHour.kwds 屬性返回應用於給定偏移量的關鍵字參數。

# import pandas as pd

import pandas as pd


# 創建時間戳

ts = pd.Timestamp( ’ 2019-10-10 11:15:00’ code> )


# 創建偏移量

bh = pd.tseries.offse ts.BusinessHour (offset = datetime.timedelta (小時 = 1 ))


# 打印時間戳

print (ts)


# 打印偏移量

print (bh)

輸出:

現在我們將向此時間戳對象添加營業時間偏移量以增加日期時間值……我們還將打印出應用於給定偏移量的參數關鍵字。

# 給指定時間戳添加營業時間偏移

new_timestamp = ts + bh

< p>
# 打印更新的時間戳

print (new_timestamp)


# 打印關鍵字參數
# 適用於給定的偏移量

print (bh.kwds)

輸出:

正如我們在輸出中看到的,我們已經成功地創建了一個偏移量並將其添加到給定的時間戳中。我們還打印了應用於給定偏移量的關鍵字參數。

我們希望本文能幫助您解決問題。 除了 蟒蛇 | Pandas tseries.offsets.BusinessHour.kwds,查看其他與 Python functions 相關的主題。

想在 Python 中出類拔萃? 查看我們對 最佳 Python 在線課程 2023的評論。 如果您對數據科學感興趣,請查看如何學習 R 編程

順便說一句,此材料也有其他語言版本:



Javier Gonzalez

Tallinn | 2023-03-30

Python functions是每一个有点混乱的😭 蟒蛇 | Pandas tseries.offsets.BusinessHour.kwds不是我遇到的唯一问题. 將在我的學士論文中使用它

Schneider Innsbruck

Rome | 2023-03-30

简单地说,很清楚。谢谢你的分享。蟒蛇 | Pandas tseries.offsets.BusinessHour.kwds和其他问题的Python functions一直是我的弱点😁。. 我只是不太確定這是最好的方法

Anna Krasiko

Vigrinia | 2023-03-30

谢谢你的解释! 我被蟒蛇 | Pandas tseries.offsets.BusinessHour.kwds卡住了几个小时。了几个小时,最后终于完成了 🤗. 我只希望不再出現

Shop

Gifts for programmers

Learn programming in R: courses

$FREE
Gifts for programmers

Best Python online courses for 2022

$FREE
Gifts for programmers

Best laptop for Fortnite

$399+
Gifts for programmers

Best laptop for Excel

$
Gifts for programmers

Best laptop for Solidworks

$399+
Gifts for programmers

Best laptop for Roblox

$399+
Gifts for programmers

Best computer for crypto mining

$499+
Gifts for programmers

Best laptop for Sims 4

$

Latest questions

PythonStackOverflow

Common xlabel/ylabel for matplotlib subplots

1947 answers

PythonStackOverflow

Check if one list is a subset of another in Python

1173 answers

PythonStackOverflow

How to specify multiple return types using type-hints

1002 answers

PythonStackOverflow

Printing words vertically in Python

909 answers

PythonStackOverflow

Python Extract words from a given string

798 answers

PythonStackOverflow

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

606 answers

PythonStackOverflow

Python os.path.join () method

384 answers

PythonStackOverflow

Flake8: Ignore specific warning for entire file

360 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

How to specify multiple return types using type-hints

Printing words vertically in Python

Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries

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