本文簡要介紹 python 語言中 numpy.datetime_data
的用法。
用法:
numpy.datetime_data(dtype, /)
獲取有關日期或時間類型的步長的信息。
返回的元組可以作為
numpy.datetime64
和numpy.timedelta64
的第二個參數傳遞。- dtype: 類型
dtype 對象,必須是
datetime64
或timedelta64
類型。
- unit: str
此 dtype 所基於的日期時間單位。
- count: int
一個步驟中的基本單位數。
參數:
返回:
例子:
>>> dt_25s = np.dtype('timedelta64[25s]') >>> np.datetime_data(dt_25s) ('s', 25) >>> np.array(10, dt_25s).astype('timedelta64[s]') array(250, dtype='timedelta64[s]')
結果可用於構造使用與 timedelta 相同單位的日期時間
>>> np.datetime64('2010', np.datetime_data(dt_25s)) numpy.datetime64('2010-01-01T00:00:00','25s')
相關用法
- Python numpy datetime_as_string用法及代碼示例
- Python numpy dtype.isbuiltin用法及代碼示例
- Python numpy dtype.shape用法及代碼示例
- Python numpy dtype.ndim用法及代碼示例
- Python numpy dtype.alignment用法及代碼示例
- Python numpy diagonal用法及代碼示例
- Python numpy dtype用法及代碼示例
- Python numpy dtype.names用法及代碼示例
- Python numpy dtype.__class_getitem__用法及代碼示例
- Python numpy divmod用法及代碼示例
- Python numpy dtype.flags用法及代碼示例
- Python numpy diagflat用法及代碼示例
- Python numpy dtype.fields用法及代碼示例
- Python numpy dtype.subdtype用法及代碼示例
- Python numpy delete用法及代碼示例
- Python numpy dtype.descr用法及代碼示例
- Python numpy dec.setastest用法及代碼示例
- Python numpy divide用法及代碼示例
- Python numpy dtype.kind用法及代碼示例
- Python numpy dtype.metadata用法及代碼示例
- Python numpy diag用法及代碼示例
- Python numpy dsplit用法及代碼示例
- Python numpy dec.slow用法及代碼示例
- Python numpy dtype.newbyteorder用法及代碼示例
- Python numpy digitize用法及代碼示例
注:本文由純淨天空篩選整理自numpy.org大神的英文原創作品 numpy.datetime_data。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。