Exemplo n.º 1
0
 def test_infer_datetime_units(self):
     for dates, expected in [
         (pd.date_range('1900-01-01',
                        periods=5), 'days since 1900-01-01 00:00:00'),
         (pd.date_range('1900-01-01 12:00:00', freq='H',
                        periods=2), 'hours since 1900-01-01 12:00:00'),
         (['1900-01-01', '1900-01-02',
           '1900-01-02 00:00:01'], 'seconds since 1900-01-01 00:00:00'),
         (pd.to_datetime(['1900-01-01', '1900-01-02',
                          'NaT']), 'days since 1900-01-01 00:00:00'),
         (pd.to_datetime(['1900-01-01', '1900-01-02T00:00:00.005']),
          'seconds since 1900-01-01 00:00:00'),
         (pd.to_datetime(['NaT',
                          '1900-01-01']), 'days since 1900-01-01 00:00:00'),
         (pd.to_datetime(['NaT']), 'days since 1970-01-01 00:00:00'),
     ]:
         self.assertEqual(expected, conventions.infer_datetime_units(dates))
Exemplo n.º 2
0
 def test_infer_datetime_units(self):
     for dates, expected in [(pd.date_range('1900-01-01', periods=5),
                              'days since 1900-01-01 00:00:00'),
                             (pd.date_range('1900-01-01 12:00:00', freq='H',
                                            periods=2),
                              'hours since 1900-01-01 12:00:00'),
                             (['1900-01-01', '1900-01-02',
                               '1900-01-02 00:00:01'],
                              'seconds since 1900-01-01 00:00:00'),
                             (pd.to_datetime(['1900-01-01', '1900-01-02', 'NaT']),
                              'days since 1900-01-01 00:00:00'),
                             (pd.to_datetime(['1900-01-01',
                                              '1900-01-02T00:00:00.005']),
                              'seconds since 1900-01-01 00:00:00'),
                             (pd.to_datetime(['NaT', '1900-01-01']),
                              'days since 1900-01-01 00:00:00'),
                             (pd.to_datetime(['NaT']),
                              'days since 1970-01-01 00:00:00'),
                             ]:
         self.assertEqual(expected, conventions.infer_datetime_units(dates))