Timestamp 객체에서 현재 날짜와 시간을 가져오고 timestamp.today()를 사용합니다. 방법.
먼저 필요한 라이브러리를 가져옵니다 -
import pandas as pd import datetime
Pandas에서 타임스탬프 생성
timestamp = pd.Timestamp(datetime.datetime(2021, 10, 10))
타임스탬프 표시
print("Timestamp: ", timestamp) 현재 날짜 및 시간 가져오기
res = timestamp.today()
예시
다음은 코드입니다.
import pandas as pd
import datetime
# set the timestamp in Pandas
timestamp = pd.Timestamp(datetime.datetime(2021, 10, 10))
# display the Timestamp
print("Timestamp: ", timestamp)
# display the day from given timestamp
print("Day Name:", timestamp.day_name())
# getting the current date and time
res = timestamp.today()
# display the current date and time
print("\nToday's Date and time...\n", res)
# display the current day
print("Today's Day:", res.day_name()) 출력
그러면 다음 코드가 생성됩니다.
Timestamp: 2021-10-10 00:00:00 Day Name: Sunday Today's Date and time... 2021-10-03 13:22:28.891506 Today's Day: Sunday