Skip to content

Commit bb76ecf

Browse files
Fixes in table when strings stored as objects
1 parent 10766f6 commit bb76ecf

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

xdeps/table.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def __getitem__(self, key):
9898
raise IndexError(
9999
f"Cannot find `{key}` in table index `{self.table._index}`")
100100
elif hasattr(key, "dtype"):
101-
if key.dtype.kind in "SU":
101+
if key.dtype.kind in "SUO":
102102
if self.table._multiple_row_selections:
103103
mask[self.table._get_names_indices(key)] = True
104104
else:
@@ -220,7 +220,7 @@ def __init__(
220220
index_cache=None,
221221
cast_strings=True
222222
):
223-
self._data = data
223+
self._data = {kk: data[kk] for kk in data.keys()}
224224

225225
self._col_names = list(data.keys() if col_names is None else col_names)
226226
for kk in self._col_names:
@@ -229,7 +229,8 @@ def __init__(
229229
raise ValueError(f"Column `{kk}` is not a numpy array")
230230
else:
231231
if cast_strings and vv.dtype.kind in "SU":
232-
data[kk] = np.array(vv, dtype=object)
232+
vv = np.array(vv, dtype=object)
233+
self._data[kk] = vv
233234
self._index = index
234235
self._count_sep = count_sep
235236
self._offset_sep = offset_sep
@@ -550,7 +551,7 @@ def show(
550551
colwidth = len(cc)
551552
width += colwidth + 1
552553
if width < maxwidth:
553-
if coltype in "SU":
554+
if coltype in "SUO":
554555
fmt.append("%%-%ds" % (colwidth))
555556
else:
556557
fmt.append("%%%ds" % colwidth)

0 commit comments

Comments
 (0)