本文整理匯總了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