|
29 | 29 | from datetime import datetime
|
30 | 30 |
|
31 | 31 | from pandas import DataFrame, Series, Index, MultiIndex, isnull
|
| 32 | +from pandas import to_timedelta |
32 | 33 | import pandas.compat as compat
|
33 | 34 | from pandas.compat import StringIO, range, lrange
|
34 | 35 | from pandas.core.datetools import format as date_format
|
35 | 36 |
|
36 | 37 | import pandas.io.sql as sql
|
37 | 38 | import pandas.util.testing as tm
|
| 39 | +from pandas import _np_version_under1p7 |
38 | 40 |
|
39 | 41 |
|
40 | 42 | try:
|
@@ -480,6 +482,17 @@ def test_date_and_index(self):
|
480 | 482 | self.assertTrue(issubclass(df.IntDateCol.dtype.type, np.datetime64),
|
481 | 483 | "IntDateCol loaded with incorrect type")
|
482 | 484 |
|
| 485 | + def test_timedelta(self): |
| 486 | + # see #6921 |
| 487 | + if _np_version_under1p7: |
| 488 | + raise nose.SkipTest("test only valid in numpy >= 1.7") |
| 489 | + |
| 490 | + df = to_timedelta(Series(['00:00:01', '00:00:03'], name='foo')).to_frame() |
| 491 | + with tm.assert_produces_warning(UserWarning): |
| 492 | + df.to_sql('test_timedelta', self.conn) |
| 493 | + result = sql.read_sql_query('SELECT * FROM test_timedelta', self.conn) |
| 494 | + tm.assert_series_equal(result['foo'], df['foo'].astype('int64')) |
| 495 | + |
483 | 496 | def test_to_sql_index_label(self):
|
484 | 497 | temp_frame = DataFrame({'col1': range(4)})
|
485 | 498 |
|
|
0 commit comments