Python | Panda tseries.offsets.BusinessHour.kwds

È possibile creare DateOffset per spostare le date di un numero specificato di date valide. Ad esempio, Bday (2) può essere aggiunto a una data per spostarla in avanti di due giorni lavorativi. Se la data non inizia con una data valida, viene prima spostata su una data valida e quindi viene generato un offset.

tseries.offsets.BusinessHour.kwds panda tseries.offsets.BusinessHour.kwds restituisce l’argomento della parola chiave applicato all’oggetto offset specificato.

Sintassi: pandas.tseries.offsets.BusinessHour.kwds

Parametro: Nessuno

< p> Resi: kwds

Esempio n. 1: Usa il pandas.tseries.offsets.BusinessHour.kwds per restituire l’argomento della parola chiave applicato all’offset specificato.

Output:

Ora aggiungeremo un offset orario lavorativo a questo oggetto timestamp per incrementare il valore datetime. Stamperemo anche la parola chiave argomento applicata all’offset specificato.

# importa panda come pd

importa panda come pd


# Crea un timestamp

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


# Crea offset

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


# Stampa timestamp

print (ts)


# Stampa offset

print (bh)

# Aggiunta di una differenza di orario lavorativo al timestamp specificato

new_timestamp = ts + bh

< p>
# Stampa timestamp aggiornato

print (new_timestamp)


# stampa l’argomento della parola chiave
# si applica a l’offset dato

print (bh.kwds)

Output:

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

Come possiamo vedere nell’output, abbiamo creato con successo un offset e lo abbiamo aggiunto al timestamp specificato. abbiamo anche stampato l’argomento della parola chiave applicato all’offset specificato.

Esempio n. 2: utilizza l’attributo pandas.tseries.offsets.BusinessHour.kwds per restituire l’argomento della parola chiave applicato all’offset specificato.

# importa panda come pd

importa panda come pd


# Crea un timestamp

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


# Crea offset

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


# Stampa timestamp

print (ts)


# Stampa offset

print (bh)

Output:

Ora aggiungeremo un offset dell’ora di lavoro a questo oggetto timestamp per aumentare il valore datetime ... Stamperemo anche la parola chiave argomento applicata all’offset specificato.

# Aggiunta di una differenza di orario lavorativo al timestamp specificato

new_timestamp = ts + bh

< p>
# Stampa timestamp aggiornato

print (new_timestamp)


# stampa l’argomento della parola chiave
# si applica a l’offset dato

print (bh.kwds)

Output:

Come possiamo vedere nell’output, abbiamo creato con successo un offset e lo abbiamo aggiunto al timestamp specificato. abbiamo anche stampato l’argomento della parola chiave applicato all’offset specificato.

Ci auguriamo che questo articolo ti abbia aiutato a risolvere il problema. Oltre a Python | Panda tseries.offsets.BusinessHour.kwds, controlla altri argomenti relativi a Python functions.

Vuoi eccellere in Python? Consulta la nostra recensione dei migliori corsi online Python 2023. Se sei interessato alla scienza dei dati, controlla anche come imparare a programmare in R.

A proposito, questo materiale è disponibile anche in altre lingue:



Xu Wu

Paris | 2023-04-01

Forse ci sono altre risposte? Cosa significa esattamente Python | Panda tseries.offsets.BusinessHour.kwds significa esattamente?. Spero solo che non emerga più

Cornwall Richtgofen

Texas | 2023-04-01

Grazie per le spiegazioni! Sono rimasto bloccato con Python | Panda tseries.offsets.BusinessHour.kwds per alcune ore, finalmente l'ho fatto 🤗. Spero solo che non emerga più

Xu Sikorski

Massachussetts | 2023-04-01

Forse ci sono altre risposte? Cosa significa esattamente Python | Panda tseries.offsets.BusinessHour.kwds significa esattamente?. Spero solo che non emerga più

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