-2
현재 시간 범위를 에포크 형식으로 가져와야합니다 (시작부터 끝까지, 두 변수, 밀리 초 단위의 에포크 형식). 그렇게하는 방법? 누군가 이미이 작업을 수행하고 도움을 줄 수 있습니까?에포크 형식으로 날짜 범위를 가져와야합니다.
현재 시간 범위를 에포크 형식으로 가져와야합니다 (시작부터 끝까지, 두 변수, 밀리 초 단위의 에포크 형식). 그렇게하는 방법? 누군가 이미이 작업을 수행하고 도움을 줄 수 있습니까?에포크 형식으로 날짜 범위를 가져와야합니다.
하지 팬더 :
from datetime import datetime
import calendar
epoch = datetime.utcfromtimestamp(0)
def unix_time(dt):
return (dt - epoch).total_seconds() * 1000.0
today = datetime.now()
lastDay = calendar.monthrange(today.year, today.month)[1]
firstDayOfMonth = today.replace(day=1)
lastDayofMonth = today.replace(day=lastDay)
firstEpoch = unix_time(firstDayOfMonth)
lastEpoch = unix_time(lastDayOfMonth)
팬더 문서에서 : From timestamp to epoch. datetime을 int64로 변환 한 다음 변환 단위로 나눕니다. 하지만, 일반적으로
import pandas as pd
def to_epoch(**kwargs):
"""returns: NumPy ndarray."""
stamps = pd.date_range(**kwargs)
return stamps.view('int64') // pd.Timedelta(1, unit='s')
to_epoch(start='2017-04-01', end='2017-04-30')
array([1491004800, 1491091200, 1491177600, 1491264000, 1491350400,
1491436800, 1491523200, 1491609600, 1491696000, 1491782400,
1491868800, 1491955200, 1492041600, 1492128000, 1492214400,
1492300800, 1492387200, 1492473600, 1492560000, 1492646400,
1492732800, 1492819200, 1492905600, 1492992000, 1493078400,
1493164800, 1493251200, 1493337600, 1493424000, 1493510400])
또는 [파이썬에서 획기적인하는 날짜 시간의 열 변환 (https://stackoverflow.com/questions/35630098/convert-a- epoch-in-python에서 column-of-datetimes) –