當前位置: 首頁>>代碼示例>>Python>>正文


Python Timestamp.now方法代碼示例

本文整理匯總了Python中pandas.Timestamp.now方法的典型用法代碼示例。如果您正苦於以下問題:Python Timestamp.now方法的具體用法?Python Timestamp.now怎麽用?Python Timestamp.now使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pandas.Timestamp的用法示例。


在下文中一共展示了Timestamp.now方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_now

# 需要導入模塊: from pandas import Timestamp [as 別名]
# 或者: from pandas.Timestamp import now [as 別名]
def test_now(self):
        # GH#9000
        ts_from_string = Timestamp('now')
        ts_from_method = Timestamp.now()
        ts_datetime = datetime.now()

        ts_from_string_tz = Timestamp('now', tz='US/Eastern')
        ts_from_method_tz = Timestamp.now(tz='US/Eastern')

        # Check that the delta between the times is less than 1s (arbitrarily
        # small)
        delta = Timedelta(seconds=1)
        assert abs(ts_from_method - ts_from_string) < delta
        assert abs(ts_datetime - ts_from_method) < delta
        assert abs(ts_from_method_tz - ts_from_string_tz) < delta
        assert (abs(ts_from_string_tz.tz_localize(None) -
                    ts_from_method_tz.tz_localize(None)) < delta) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:19,代碼來源:test_timestamp.py

示例2: test_class_ops_pytz

# 需要導入模塊: from pandas import Timestamp [as 別名]
# 或者: from pandas.Timestamp import now [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)) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:21,代碼來源:test_timestamp.py

示例3: test_timestamp

# 需要導入模塊: from pandas import Timestamp [as 別名]
# 或者: from pandas.Timestamp import now [as 別名]
def test_timestamp(self):
        # GH#17329
        # tz-naive --> treat it as if it were UTC for purposes of timestamp()
        ts = Timestamp.now()
        uts = ts.replace(tzinfo=utc)
        assert ts.timestamp() == uts.timestamp()

        tsc = Timestamp('2014-10-11 11:00:01.12345678', tz='US/Central')
        utsc = tsc.tz_convert('UTC')

        # utsc is a different representation of the same time
        assert tsc.timestamp() == utsc.timestamp()

        if PY3:
            # datetime.timestamp() converts in the local timezone
            with tm.set_timezone('UTC'):
                # should agree with datetime.timestamp method
                dt = ts.to_pydatetime()
                assert dt.timestamp() == ts.timestamp() 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:21,代碼來源:test_unary_ops.py

示例4: test_class_ops_dateutil

# 需要導入模塊: from pandas import Timestamp [as 別名]
# 或者: from pandas.Timestamp import now [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)) 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:21,代碼來源:test_timestamp.py

示例5: _DWX_MTX_SEND_MARKETDATA_REQUEST_

# 需要導入模塊: from pandas import Timestamp [as 別名]
# 或者: from pandas.Timestamp import now [as 別名]
def _DWX_MTX_SEND_MARKETDATA_REQUEST_(self,
                                 _symbol='EURUSD',
                                 _timeframe=1,
                                 _start='2019.01.04 17:00:00',
                                 _end=Timestamp.now().strftime('%Y.%m.%d %H:%M:00')):
                                 #_end='2019.01.04 17:05:00'):
        
        _msg = "{};{};{};{};{}".format('DATA',
                                     _symbol,
                                     _timeframe,
                                     _start,
                                     _end)
        # Send via PUSH Socket
        self.remote_send(self._PUSH_SOCKET, _msg)
    
    
    ########################################################################## 
開發者ID:darwinex,項目名稱:dwx-zeromq-connector,代碼行數:19,代碼來源:DWX_ZeroMQ_Connector_v2_0_1_RC8.py

示例6: _DWX_MTX_SEND_MARKETHIST_REQUEST_

# 需要導入模塊: from pandas import Timestamp [as 別名]
# 或者: from pandas.Timestamp import now [as 別名]
def _DWX_MTX_SEND_MARKETHIST_REQUEST_(self,
                                 _symbol='EURUSD',
                                 _timeframe=1,
                                 _start='2019.01.04 17:00:00',
                                 _end=Timestamp.now().strftime('%Y.%m.%d %H:%M:00')):
                                 #_end='2019.01.04 17:05:00'):
        
        _msg = "{};{};{};{};{}".format('HIST',
                                     _symbol,
                                     _timeframe,
                                     _start,
                                     _end)
        # Send via PUSH Socket
        self.remote_send(self._PUSH_SOCKET, _msg)
    
    
    ########################################################################## 
開發者ID:darwinex,項目名稱:dwx-zeromq-connector,代碼行數:19,代碼來源:DWX_ZeroMQ_Connector_v2_0_2_RC1.py

示例7: get_file_info

# 需要導入模塊: from pandas import Timestamp [as 別名]
# 或者: from pandas.Timestamp import now [as 別名]
def get_file_info(self):
        """Internal method to get the file information.

        Returns
        -------
        file_info: dict
            dictionary with file information.

        """
        # Check if file_info already exists
        if hasattr(self, "file_info"):
            file_info = self.file_info
        else:
            file_info = {"date_created": Timestamp.now()}

        file_info["date_modified"] = Timestamp.now()
        file_info["pastas_version"] = __version__

        try:
            file_info["owner"] = getlogin()
        except:
            file_info["owner"] = "Unknown"

        return file_info 
開發者ID:pastas,項目名稱:pastas,代碼行數:26,代碼來源:model.py

示例8: test_td_sub_mixed_most_timedeltalike_object_dtype_array

# 需要導入模塊: from pandas import Timestamp [as 別名]
# 或者: from pandas.Timestamp import now [as 別名]
def test_td_sub_mixed_most_timedeltalike_object_dtype_array(self):
        # GH#21980
        now = Timestamp.now()
        arr = np.array([now,
                        Timedelta('1D'),
                        np.timedelta64(2, 'h')])
        exp = np.array([now - Timedelta('1D'),
                        Timedelta('0D'),
                        np.timedelta64(2, 'h') - Timedelta('1D')])
        res = arr - Timedelta('1D')
        tm.assert_numpy_array_equal(res, exp) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:13,代碼來源:test_arithmetic.py

示例9: test_td_rsub_mixed_most_timedeltalike_object_dtype_array

# 需要導入模塊: from pandas import Timestamp [as 別名]
# 或者: from pandas.Timestamp import now [as 別名]
def test_td_rsub_mixed_most_timedeltalike_object_dtype_array(self):
        # GH#21980
        now = Timestamp.now()
        arr = np.array([now,
                        Timedelta('1D'),
                        np.timedelta64(2, 'h')])
        with pytest.raises(TypeError):
            Timedelta('1D') - arr 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:10,代碼來源:test_arithmetic.py

示例10: test_td_add_mixed_timedeltalike_object_dtype_array

# 需要導入模塊: from pandas import Timestamp [as 別名]
# 或者: from pandas.Timestamp import now [as 別名]
def test_td_add_mixed_timedeltalike_object_dtype_array(self, op):
        # GH#21980
        now = Timestamp.now()
        arr = np.array([now,
                        Timedelta('1D')])
        exp = np.array([now + Timedelta('1D'),
                        Timedelta('2D')])
        res = op(arr, Timedelta('1D'))
        tm.assert_numpy_array_equal(res, exp) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:11,代碼來源:test_arithmetic.py


注:本文中的pandas.Timestamp.now方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。