Để lấy thành phần phút (minute) trong giờ của đối tượng Period, sử dụng thuộc tính period.minute.
Các bước thực hiện
- Import thư viện:
import pandas as pd - Tạo hai Period object:
period1 = pd.Period("2020-09-23 05:55:30")period2 = pd.Period(freq="T", year=2021, month=7, day=16, hour=2, minute=35)(tần suất phút)
- Truy cập
period1.minutevàperiod2.minute.
Ví dụ hoàn chỉnh
import pandas as pd
period1 = pd.Period("2020-09-23 05:55:30")
period2 = pd.Period(freq="T", year=2021, month=7, day=16, hour=2, minute=35)
print("Period1...\n", period1)
print("Period2...\n", period2)
res1 = period1.minute
res2 = period2.minute
print("\nMinute of the hour from the 1st Period object ...\n", res1) # 55
print("\nMinute of the hour from the 2nd Period object...\n", res2) # 35
Kết quả
Period1... 2020-09-23 05:55:30
Period2... 2021-07-16 02:35
Minute of the hour from the 1st Period object ... 55
Minute of the hour from the 2nd Period object... 35