Python是進行數據分析的一種出色語言,主要是因為以數據為中心的python軟件包具有奇妙的生態係統。 Pandas是其中的一種,使導入和分析數據更加容易。
Pandas DatetimeIndex.microsecond
屬性輸出一個Index對象,其中包含存在於DatetimeIndex對象的每個條目中的微秒值。
用法: DatetimeIndex.microsecond
返回:索引包含微秒。
範例1:采用DatetimeIndex.microsecond
屬性以查找DatetimeIndex對象中存在的微秒值。
# importing pandas as pd
import pandas as pd
# Create the DatetimeIndex
# Here 'U' represents microseconds
didx = pd.DatetimeIndex(start ='2014-08-01 10:05:45', freq ='U',
periods = 5, tz ='Asia/Calcutta')
# Print the DatetimeIndex
print(didx)
輸出:
現在,我們要查找DatetimeIndex對象中存在的所有微秒值。
# find all the microsecond values
# present in the object
didx.microsecond
輸出:
正如我們在輸出中看到的那樣,該函數返回了一個Index對象,其中包含DatetimeIndex對象的每個條目中存在的微秒值。
範例2:采用DatetimeIndex.microsecond
屬性以查找DatetimeIndex對象中存在的微秒值。
# importing pandas as pd
import pandas as pd
# Create the DatetimeIndex
didx = pd.DatetimeIndex(['2014-08-01 10:05:45.000001 + 05:30',
'2014-08-01 10:05:45.000010 + 05:30'])
# Print the DatetimeIndex
print(didx)
輸出:
現在,我們要查找DatetimeIndex對象中存在的所有微秒值。
# find all the microsecond values
# present in the object
didx.microsecond
輸出:
正如我們在輸出中看到的那樣,該函數返回了一個Index對象,其中包含DatetimeIndex對象的每個條目中存在的微秒值。
相關用法
- Python pandas.map()用法及代碼示例
- Python Pandas Series.str.len()用法及代碼示例
- Python Pandas.factorize()用法及代碼示例
- Python Pandas TimedeltaIndex.name用法及代碼示例
- Python Pandas dataframe.ne()用法及代碼示例
- Python Pandas Series.between()用法及代碼示例
- Python Pandas DataFrame.where()用法及代碼示例
- Python Pandas Series.add()用法及代碼示例
- Python Pandas.pivot_table()用法及代碼示例
- Python Pandas Series.mod()用法及代碼示例
- Python Pandas Dataframe.at[ ]用法及代碼示例
- Python Pandas Dataframe.iat[ ]用法及代碼示例
- Python Pandas.pivot()用法及代碼示例
- Python Pandas dataframe.mul()用法及代碼示例
- Python Pandas.melt()用法及代碼示例
注:本文由純淨天空篩選整理自Shubham__Ranjan大神的英文原創作品 Python | Pandas DatetimeIndex.microsecond。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。