ในการแสดงอาร์กิวเมนต์ของคีย์เวิร์ดที่ใช้กับออบเจ็กต์ BusinessDay Offset ที่กำหนด ให้ใช้คุณสมบัติ BusinessDay.kwds ใน Pandas
ขั้นแรก นำเข้าไลบรารีที่จำเป็น -
import datetime import pandas as pd
ตั้งค่าอ็อบเจ็กต์ประทับเวลาใน Pandas -
timestamp = pd.Timestamp('2021-10-30 01:55:02.000045')
สร้างออฟเซ็ตวันธุรกิจ BusinessDay เป็นคลาสย่อย DateOffset -
bdOffset = pd.tseries.offsets.BusinessDay(offset = datetime.timedelta(hours = 7, minutes = 7))
แสดงการประทับเวลาที่อัปเดต -
print("\nUpdated Timestamp...\n",timestamp + bdOffset)
แสดงอาร์กิวเมนต์คำหลัก -
print("\nKeyword arguments on the given BusinessDay Offset...\n",bdOffset.kwds) ตัวอย่าง
ต่อไปนี้เป็นรหัส -
import datetime
import pandas as pd
# Set the timestamp object in Pandas
timestamp = pd.Timestamp('2021-10-30 01:55:02.000045')
# Display the Timestamp
print("Timestamp...\n",timestamp)
# Create the BusinessDay Offset
# BusinessDay is the DateOffset subclass
bdOffset = pd.tseries.offsets.BusinessDay(offset = datetime.timedelta(hours = 7, minutes = 7))
# Display the BusinessDay Offset
print("\nBusinessDay Offset...\n",bdOffset)
# Display the Updated Timestamp
print("\nUpdated Timestamp...\n",timestamp + bdOffset)
# return the frequency applied on the given BusinessDay object as a string
print("\nFrequency on the given BusinessDay Offset...\n",bdOffset.freqstr)
# Display the keyword arguments
print("\nKeyword arguments on the given BusinessDay Offset...\n",bdOffset.kwds) ผลลัพธ์
สิ่งนี้จะสร้างรหัสต่อไปนี้ -
Timestamp...
2021-10-30 01:55:02.000045
BusinessDay Offset...
<BusinessDay: offset=datetime.timedelta(seconds=25620)>
Updated Timestamp...
2021-11-01 09:02:02.000045
Frequency on the given BusinessDay Offset...
B+7H7Min
Keyword arguments on the given BusinessDay Offset...
{'offset': datetime.timedelta(seconds=25620)}