本文整理汇总了Python中pandas.core.tools.datetimes._guess_datetime_format_for_array方法的典型用法代码示例。如果您正苦于以下问题:Python datetimes._guess_datetime_format_for_array方法的具体用法?Python datetimes._guess_datetime_format_for_array怎么用?Python datetimes._guess_datetime_format_for_array使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandas.core.tools.datetimes
的用法示例。
在下文中一共展示了datetimes._guess_datetime_format_for_array方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_guess_datetime_format_for_array
# 需要导入模块: from pandas.core.tools import datetimes [as 别名]
# 或者: from pandas.core.tools.datetimes import _guess_datetime_format_for_array [as 别名]
def test_guess_datetime_format_for_array(self):
expected_format = '%Y-%m-%d %H:%M:%S.%f'
dt_string = datetime(2011, 12, 30, 0, 0, 0).strftime(expected_format)
test_arrays = [
np.array([dt_string, dt_string, dt_string], dtype='O'),
np.array([np.nan, np.nan, dt_string], dtype='O'),
np.array([dt_string, 'random_string'], dtype='O'),
]
for test_array in test_arrays:
assert tools._guess_datetime_format_for_array(
test_array) == expected_format
format_for_string_of_nans = tools._guess_datetime_format_for_array(
np.array(
[np.nan, np.nan, np.nan], dtype='O'))
assert format_for_string_of_nans is None
示例2: test_guess_datetime_format_for_array
# 需要导入模块: from pandas.core.tools import datetimes [as 别名]
# 或者: from pandas.core.tools.datetimes import _guess_datetime_format_for_array [as 别名]
def test_guess_datetime_format_for_array(self):
tm._skip_if_not_us_locale()
expected_format = '%Y-%m-%d %H:%M:%S.%f'
dt_string = datetime(2011, 12, 30, 0, 0, 0).strftime(expected_format)
test_arrays = [
np.array([dt_string, dt_string, dt_string], dtype='O'),
np.array([np.nan, np.nan, dt_string], dtype='O'),
np.array([dt_string, 'random_string'], dtype='O'),
]
for test_array in test_arrays:
assert tools._guess_datetime_format_for_array(
test_array) == expected_format
format_for_string_of_nans = tools._guess_datetime_format_for_array(
np.array(
[np.nan, np.nan, np.nan], dtype='O'))
assert format_for_string_of_nans is None