Skip to content

Saving Panel with float index to HDFStore fails #454

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
andreas-h opened this issue Dec 6, 2011 · 2 comments
Closed

Saving Panel with float index to HDFStore fails #454

andreas-h opened this issue Dec 6, 2011 · 2 comments
Labels
Milestone

Comments

@andreas-h
Copy link
Contributor

Hi,

the following code produces a ValueError: unrecognized index type <type 'float'>:

import datetime
import pandas
timeidx = pandas.DateRange(start=datetime.datetime(2009,1,1),
                   end=datetime.datetime(2009,12,31),
                   offset=pandas.datetools.MonthEnd())
lons_coarse = np.linspace(-177.5, 177.5, 72)
lats_coarse = np.linspace(-87.5, 87.5, 36)
P = pandas.Panel(items=timeidx, major_axis=lons_coarse, minor_axis=lats_coarse)
D = pandas.DataFrame(data=np.random.randn(72*36).reshape((72,36)),index=lons_coarse, columns=lats_coarse)
P[datetime.datetime(2009,2,28)] = D
H = pandas.HDFStore("test.h5", complevel=9, complib='zlib')
H['test'] = P
H.close()
@andreas-h
Copy link
Contributor Author


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/home/username/src/pydoas/<ipython-input-14-553ce2906e23> in <module>()
----> 1 H['test'] = P

/home/username/.virtualenvs/pydoas/lib/python2.7/site-packages/pandas/io/pytables.pyc in __setitem__(self, key, value)
    120 
    121     def __setitem__(self, key, value):
--> 122         self.put(key, value)
    123 
    124     def __len__(self):

/home/username/.virtualenvs/pydoas/lib/python2.7/site-packages/pandas/io/pytables.pyc in put(self, key, value, table, append, compression)
    258         """
    259         self._write_to_group(key, value, table=table, append=append,
--> 260                              comp=compression)
    261 
    262     def _get_handler(self, op, kind):

/home/username/.virtualenvs/pydoas/lib/python2.7/site-packages/pandas/io/pytables.pyc in _write_to_group(self, key, value, table, append, comp)
    326             wrapper = lambda value: handler(group, value)
    327 
--> 328         wrapper(value)
    329         group._v_attrs.pandas_type = kind
    330 

/home/username/.virtualenvs/pydoas/lib/python2.7/site-packages/pandas/io/pytables.pyc in <lambda>(value)
    324 
    325             handler = self._get_handler(op='write', kind=kind)
--> 326             wrapper = lambda value: handler(group, value)
    327 
    328         wrapper(value)

/home/username/.virtualenvs/pydoas/lib/python2.7/site-packages/pandas/io/pytables.pyc in _write_wide(self, group, panel)
    391     def _write_wide(self, group, panel):
    392         panel._consolidate_inplace()
--> 393         self._write_block_manager(group, panel._data)
    394 
    395     def _read_wide(self, group, where=None):

/home/username/.virtualenvs/pydoas/lib/python2.7/site-packages/pandas/io/pytables.pyc in _write_block_manager(self, group, data)
    346         group._v_attrs.ndim = data.ndim
    347         for i, ax in enumerate(data.axes):
--> 348             self._write_index(group, 'axis%d' % i, ax)
    349 
    350         # Supporting mixed-type DataFrame objects...nontrivial


/home/username/.virtualenvs/pydoas/lib/python2.7/site-packages/pandas/io/pytables.pyc in _write_index(self, group, key, index)
    438         else:
    439             setattr(group._v_attrs, '%s_variety' % key, 'regular')
--> 440             converted, kind, _ = _convert_index(index)
    441             self._write_array(group, key, converted)
    442             node = getattr(group, key)

/home/username/.virtualenvs/pydoas/lib/python2.7/site-packages/pandas/io/pytables.pyc in _convert_index(index)
    730         return np.asarray(values, dtype=np.int64), 'integer', atom
    731     else: # pragma: no cover
--> 732         raise ValueError('unrecognized index type %s' % type(values[0]))
    733 
    734 def _read_array(group, key):

ValueError: unrecognized index type <type 'float'>

@wesm
Copy link
Member

wesm commented Dec 12, 2011

resolved in the above commit, will be part of the 0.6.1 release but in git master now

@wesm wesm closed this as completed Dec 12, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants