本文整理汇总了Python中pandas._libs.tslib.ints_to_pydatetime方法的典型用法代码示例。如果您正苦于以下问题:Python tslib.ints_to_pydatetime方法的具体用法?Python tslib.ints_to_pydatetime怎么用?Python tslib.ints_to_pydatetime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandas._libs.tslib
的用法示例。
在下文中一共展示了tslib.ints_to_pydatetime方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __iter__
# 需要导入模块: from pandas._libs import tslib [as 别名]
# 或者: from pandas._libs.tslib import ints_to_pydatetime [as 别名]
def __iter__(self):
"""
Return an iterator over the boxed values
Yields
-------
tstamp : Timestamp
"""
# convert in chunks of 10k for efficiency
data = self.asi8
length = len(self)
chunksize = 10000
chunks = int(length / chunksize) + 1
for i in range(chunks):
start_i = i * chunksize
end_i = min((i + 1) * chunksize, length)
converted = tslib.ints_to_pydatetime(data[start_i:end_i],
tz=self.tz, freq=self.freq,
box="timestamp")
for v in converted:
yield v
示例2: _convert_datetimelike_to_object
# 需要导入模块: from pandas._libs import tslib [as 别名]
# 或者: from pandas._libs.tslib import ints_to_pydatetime [as 别名]
def _convert_datetimelike_to_object(x):
# coerce datetimelike array to object dtype
# if dtype is of datetimetz or timezone
if x.dtype.kind == _NS_DTYPE.kind:
if getattr(x, 'tz', None) is not None:
x = x.astype(object).values
else:
shape = x.shape
x = tslib.ints_to_pydatetime(x.view(np.int64).ravel(),
box="timestamp")
x = x.reshape(shape)
elif x.dtype == _TD_DTYPE:
shape = x.shape
x = tslib.ints_to_pytimedelta(x.view(np.int64).ravel(), box=True)
x = x.reshape(shape)
return x
示例3: to_pydatetime
# 需要导入模块: from pandas._libs import tslib [as 别名]
# 或者: from pandas._libs.tslib import ints_to_pydatetime [as 别名]
def to_pydatetime(self):
"""
Return Datetime Array/Index as object ndarray of datetime.datetime
objects
Returns
-------
datetimes : ndarray
"""
return tslib.ints_to_pydatetime(self.asi8, tz=self.tz)
示例4: time
# 需要导入模块: from pandas._libs import tslib [as 别名]
# 或者: from pandas._libs.tslib import ints_to_pydatetime [as 别名]
def time(self):
"""
Returns numpy array of datetime.time. The time part of the Timestamps.
"""
# If the Timestamps have a timezone that is not UTC,
# convert them into their i8 representation while
# keeping their timezone and not using UTC
if self.tz is not None and not timezones.is_utc(self.tz):
timestamps = self._local_timestamps()
else:
timestamps = self.asi8
return tslib.ints_to_pydatetime(timestamps, box="time")
示例5: timetz
# 需要导入模块: from pandas._libs import tslib [as 别名]
# 或者: from pandas._libs.tslib import ints_to_pydatetime [as 别名]
def timetz(self):
"""
Returns numpy array of datetime.time also containing timezone
information. The time part of the Timestamps.
"""
return tslib.ints_to_pydatetime(self.asi8, self.tz, box="time")
示例6: date
# 需要导入模块: from pandas._libs import tslib [as 别名]
# 或者: from pandas._libs.tslib import ints_to_pydatetime [as 别名]
def date(self):
"""
Returns numpy array of python datetime.date objects (namely, the date
part of Timestamps without timezone information).
"""
# If the Timestamps have a timezone that is not UTC,
# convert them into their i8 representation while
# keeping their timezone and not using UTC
if self.tz is not None and not timezones.is_utc(self.tz):
timestamps = self._local_timestamps()
else:
timestamps = self.asi8
return tslib.ints_to_pydatetime(timestamps, box="date")
示例7: _where_compat
# 需要导入模块: from pandas._libs import tslib [as 别名]
# 或者: from pandas._libs.tslib import ints_to_pydatetime [as 别名]
def _where_compat(mask, arr1, arr2):
if arr1.dtype == _NS_DTYPE and arr2.dtype == _NS_DTYPE:
new_vals = np.where(mask, arr1.view('i8'), arr2.view('i8'))
return new_vals.view(_NS_DTYPE)
if arr1.dtype == _NS_DTYPE:
arr1 = tslib.ints_to_pydatetime(arr1.view('i8'))
if arr2.dtype == _NS_DTYPE:
arr2 = tslib.ints_to_pydatetime(arr2.view('i8'))
return np.where(mask, arr1, arr2)