本文整理汇总了Python中pandas._libs.tslib.format_array_from_datetime方法的典型用法代码示例。如果您正苦于以下问题:Python tslib.format_array_from_datetime方法的具体用法?Python tslib.format_array_from_datetime怎么用?Python tslib.format_array_from_datetime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandas._libs.tslib
的用法示例。
在下文中一共展示了tslib.format_array_from_datetime方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: to_native_types
# 需要导入模块: from pandas._libs import tslib [as 别名]
# 或者: from pandas._libs.tslib import format_array_from_datetime [as 别名]
def to_native_types(self, slicer=None, na_rep=None, date_format=None,
quoting=None, **kwargs):
""" convert to our native types format, slicing if desired """
values = self.values
i8values = self.values.view('i8')
if slicer is not None:
i8values = i8values[..., slicer]
from pandas.io.formats.format import _get_format_datetime64_from_values
fmt = _get_format_datetime64_from_values(values, date_format)
result = tslib.format_array_from_datetime(
i8values.ravel(), tz=getattr(self.values, 'tz', None),
format=fmt, na_rep=na_rep).reshape(i8values.shape)
return np.atleast_2d(result)
示例2: _format_strings
# 需要导入模块: from pandas._libs import tslib [as 别名]
# 或者: from pandas._libs.tslib import format_array_from_datetime [as 别名]
def _format_strings(self):
""" we by definition have DO NOT have a TZ """
values = self.values
if not isinstance(values, DatetimeIndex):
values = DatetimeIndex(values)
if self.formatter is not None and callable(self.formatter):
return [self.formatter(x) for x in values]
fmt_values = format_array_from_datetime(
values.asi8.ravel(),
format=_get_format_datetime64_from_values(values,
self.date_format),
na_rep=self.nat_rep).reshape(values.shape)
return fmt_values.tolist()
示例3: _format_native_types
# 需要导入模块: from pandas._libs import tslib [as 别名]
# 或者: from pandas._libs.tslib import format_array_from_datetime [as 别名]
def _format_native_types(self, na_rep='NaT', date_format=None, **kwargs):
from pandas.io.formats.format import _get_format_datetime64_from_values
fmt = _get_format_datetime64_from_values(self, date_format)
return tslib.format_array_from_datetime(self.asi8,
tz=self.tz,
format=fmt,
na_rep=na_rep)
# -----------------------------------------------------------------
# Comparison Methods
示例4: to_native_types
# 需要导入模块: from pandas._libs import tslib [as 别名]
# 或者: from pandas._libs.tslib import format_array_from_datetime [as 别名]
def to_native_types(self, slicer=None, na_rep=None, date_format=None,
quoting=None, **kwargs):
""" convert to our native types format, slicing if desired """
values = self.values
if slicer is not None:
values = values[..., slicer]
from pandas.io.formats.format import _get_format_datetime64_from_values
format = _get_format_datetime64_from_values(values, date_format)
result = tslib.format_array_from_datetime(
values.view('i8').ravel(), tz=getattr(self.values, 'tz', None),
format=format, na_rep=na_rep).reshape(values.shape)
return np.atleast_2d(result)