本文整理匯總了Python中pandas.Timestamp.utcnow方法的典型用法代碼示例。如果您正苦於以下問題:Python Timestamp.utcnow方法的具體用法?Python Timestamp.utcnow怎麽用?Python Timestamp.utcnow使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pandas.Timestamp
的用法示例。
在下文中一共展示了Timestamp.utcnow方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_class_ops_pytz
# 需要導入模塊: from pandas import Timestamp [as 別名]
# 或者: from pandas.Timestamp import utcnow [as 別名]
def test_class_ops_pytz(self):
def compare(x, y):
assert (int(Timestamp(x).value / 1e9) ==
int(Timestamp(y).value / 1e9))
compare(Timestamp.now(), datetime.now())
compare(Timestamp.now('UTC'), datetime.now(timezone('UTC')))
compare(Timestamp.utcnow(), datetime.utcnow())
compare(Timestamp.today(), datetime.today())
current_time = calendar.timegm(datetime.now().utctimetuple())
compare(Timestamp.utcfromtimestamp(current_time),
datetime.utcfromtimestamp(current_time))
compare(Timestamp.fromtimestamp(current_time),
datetime.fromtimestamp(current_time))
date_component = datetime.utcnow()
time_component = (date_component + timedelta(minutes=10)).time()
compare(Timestamp.combine(date_component, time_component),
datetime.combine(date_component, time_component))
示例2: test_class_ops_dateutil
# 需要導入模塊: from pandas import Timestamp [as 別名]
# 或者: from pandas.Timestamp import utcnow [as 別名]
def test_class_ops_dateutil(self):
def compare(x, y):
assert (int(np.round(Timestamp(x).value / 1e9)) ==
int(np.round(Timestamp(y).value / 1e9)))
compare(Timestamp.now(), datetime.now())
compare(Timestamp.now('UTC'), datetime.now(tzutc()))
compare(Timestamp.utcnow(), datetime.utcnow())
compare(Timestamp.today(), datetime.today())
current_time = calendar.timegm(datetime.now().utctimetuple())
compare(Timestamp.utcfromtimestamp(current_time),
datetime.utcfromtimestamp(current_time))
compare(Timestamp.fromtimestamp(current_time),
datetime.fromtimestamp(current_time))
date_component = datetime.utcnow()
time_component = (date_component + timedelta(minutes=10)).time()
compare(Timestamp.combine(date_component, time_component),
datetime.combine(date_component, time_component))
示例3: run_round
# 需要導入模塊: from pandas import Timestamp [as 別名]
# 或者: from pandas.Timestamp import utcnow [as 別名]
def run_round(self, env):
t0 = pd.Timestamp.utcnow()
stats_training = []
# test runs in parallel to the training process
test = self.Test(
Env=self.Env,
actor=self.agent.model,
steps=self.stats_window or self.steps,
base_seed=self.seed+self.epochs
)
for step in range(self.steps):
action, training_stats = self.agent.act(*env.transition, train=True)
stats_training += training_stats
env.step(action)
return pandas_dict(
**env.stats(),
round_time=Timestamp.utcnow() - t0,
**test.stats().add_suffix("_test"), # this blocks until the tests have finished
round_time_total=Timestamp.utcnow() - t0,
**DataFrame(stats_training).mean(skipna=True)
)
示例4: setup_method
# 需要導入模塊: from pandas import Timestamp [as 別名]
# 或者: from pandas.Timestamp import utcnow [as 別名]
def setup_method(self, method):
self.timestamp = Timestamp(datetime.utcnow())