diff --git a/dios/dios.py b/dios/dios.py index 46a0f17760e9d96970bbd5a72031ea1811fabc2a..66583cbc25260b96dd3644a06942b4260a173218 100644 --- a/dios/dios.py +++ b/dios/dios.py @@ -479,19 +479,23 @@ class DictOfSeries: return self.copy(deep=True) def copy(self, deep=True): - if not deep: - return DictOfSeries(data=self._data, itype=self._itype, cast_policy=self._policy, fastpath=True) - - new = DictOfSeries(itype=self.itype, columns=self.columns, cast_policy=self._policy, fastpath=True) - for c in self.columns: - new._data.at[c] = self._data.at[c].copy(deep=True) - return new + if deep: + data = pd.Series(dtype='O', index=self.columns) + for c in self.columns: + data.at[c] = self._data.at[c].copy(deep=True) + else: + data = self._data + kws = dict(itype=self._itype, cast_policy=self._policy) + return DictOfSeries(data=data, fastpath=True, **kws) def copy_empty(self, columns=True): - return DictOfSeries(columns=self.columns if columns is True else None, # correct - itype=self.itype, - cast_policy=self._policy, - fastpath=True) + data = None + if columns is True: # is correct + data = pd.Series(dtype='O', index=self.columns) + for c in self.columns: + data.at[c] = pd.Series(dtype=self._data.at[c].dtype) + kws = dict(itype=self._itype, cast_policy=self._policy) + return DictOfSeries(data=data, fastpath=True, **kws) def __str__(self): return self.__repr__()