Skip to content

Commit 15bca1c

Browse files
committed
Merge branch 'master' of https://github.com/jmellen/pandas into jmellen-master
Conflicts: RELEASE.rst
2 parents 008580d + 75b5a8e commit 15bca1c

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

RELEASE.rst

+2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ pandas 0.11.1
6060
- DataFrames fetched via FRED now handle '.' as a NaN. (GH3469_)
6161
- Fix regression in a DataFrame apply with axis=1, objects were not being converted back
6262
to base dtypes correctly (GH3480_)
63+
- Fix issue when storing uint dtypes in an HDFStore. (GH3493_)
6364

6465
.. _GH3164: https://github.com/pydata/pandas/issues/3164
6566
.. _GH3251: https://github.com/pydata/pandas/issues/3251
@@ -76,6 +77,7 @@ pandas 0.11.1
7677
.. _GH3461: https://github.com/pydata/pandas/issues/3461
7778
.. _GH3448: https://github.com/pydata/pandas/issues/3448
7879
.. _GH3449: https://github.com/pydata/pandas/issues/3449
80+
.. _GH3493: https://github.com/pydata/pandas/issues/3493
7981

8082

8183
pandas 0.11.0

pandas/io/pytables.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -1284,8 +1284,17 @@ def set_atom_string(self, block, existing_col, min_itemsize, nan_rep):
12841284
def convert_string_data(self, data, itemsize):
12851285
return data.astype('S%s' % itemsize)
12861286

1287+
def get_atom_coltype(self):
1288+
""" return the PyTables column class for this column """
1289+
if self.kind.startswith('uint'):
1290+
col_name = "UInt%sCol" % self.kind[4:]
1291+
else:
1292+
col_name = "%sCol" % self.kind.capitalize()
1293+
1294+
return getattr(_tables(), col_name)
1295+
12871296
def get_atom_data(self, block):
1288-
return getattr(_tables(), "%sCol" % self.kind.capitalize())(shape=block.shape[0])
1297+
return self.get_atom_coltype()(shape=block.shape[0])
12891298

12901299
def set_atom_data(self, block):
12911300
self.kind = block.dtype.name
@@ -1383,7 +1392,7 @@ def get_atom_string(self, block, itemsize):
13831392
return _tables().StringCol(itemsize=itemsize)
13841393

13851394
def get_atom_data(self, block):
1386-
return getattr(_tables(), "%sCol" % self.kind.capitalize())()
1395+
return self.get_atom_coltype()()
13871396

13881397
def get_atom_datetime64(self, block):
13891398
return _tables().Int64Col()

pandas/io/tests/test_pytables.py

+15
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,21 @@ def test_append(self):
458458
store.append('df', df)
459459
tm.assert_frame_equal(store['df'], df)
460460

461+
# uints - test storage of uints
462+
uint_data = DataFrame({'u08' : Series(np.random.random_integers(0, high=255, size=5), dtype=np.uint8),
463+
'u16' : Series(np.random.random_integers(0, high=65535, size=5), dtype=np.uint16),
464+
'u32' : Series(np.random.random_integers(0, high=2**30, size=5), dtype=np.uint32),
465+
'u64' : Series([2**58, 2**59, 2**60, 2**61, 2**62], dtype=np.uint64)},
466+
index=np.arange(5))
467+
_maybe_remove(store, 'uints')
468+
store.append('uints', uint_data)
469+
tm.assert_frame_equal(store['uints'], uint_data)
470+
471+
# uints - test storage of uints in indexable columns
472+
_maybe_remove(store, 'uints')
473+
store.append('uints', uint_data, data_columns=['u08','u16','u32']) # 64-bit indices not yet supported
474+
tm.assert_frame_equal(store['uints'], uint_data)
475+
461476
def test_append_some_nans(self):
462477

463478
with ensure_clean(self.path) as store:

0 commit comments

Comments
 (0)