简体   繁体   中英

datetime in pandas showing the wrong value

import numpy as np
import pandas as pd
from datetime import datetime

Made variables assigned with the time:
year_= 2019
month_= 8
day_= 7
hour_= 6
sec_= 15

time_= datetime(year_,month_,day_,hour_,sec_)

But when i call time_.second it returns 0 in jupyter notebook

time_.second
0

This is because the 5th number is minutes. Not seconds.

Try:

year_= 2019
month_= 8
day_= 7
hour_= 6
min_ = 34
sec_= 15

time_= datetime(year_,month_,day_,hour_,min_,sec_)
time_.second
15

I have added the figure for minutes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM