當前位置: 首頁>>代碼示例>>Python>>正文


Python datetimes._guess_datetime_format_for_array方法代碼示例

本文整理匯總了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 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:20,代碼來源:test_tools.py

示例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 
開發者ID:securityclippy,項目名稱:elasticintel,代碼行數:21,代碼來源:test_tools.py


注:本文中的pandas.core.tools.datetimes._guess_datetime_format_for_array方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。