wesm/pandas — Issue #704: DataFrames with index dates before 1970 won't write to HDFStore
Author: duckfloats
Created: 2012-01-27 20:20:18+00:00
State: open

I'm using pandas version '0.7.0rc1' with Python 2.7 on Windows XP.

When writing HDF files, pandas tries to convert datetime index values to an ordinal using time.mktime. mktime does not support any dates before 1969.

error output shows the offending line to be:

>
> File "C:\Python27\lib\site-packages\pandas\io\pytables.py", line 697, in _convert_index
> converted = np.array([time.mktime(v.timetuple()) for v in values],
>

I suggest datetime.toordinal() instead of time.mktime(). However, doing so break existing HDF files.

test program to demonstrate the problem

```python
import pandas
import numpy

newIndex = pandas.DateRange('1/1/2000', periods=8)

newDF = pandas.DataFrame(numpy.random.randn(8, 3), index=newIndex,
columns=['A', 'B', 'C'])

oldIndex = pandas.DateRange('1/1/1950', periods=8)

oldDF = pandas.DataFrame(numpy.random.randn(8, 3), index=oldIndex,
columns=['A', 'B', 'C'])

store = pandas.io.pytables.HDFStore('store.h5')
print '--- writing new ---'
store['newDF'] = newDF

print '--- writing old ---'
store['oldDF'] = oldDF

print 'done'
```