Skip to content
Snippets Groups Projects
Commit 223b8d8b authored by Bert Palm's avatar Bert Palm 🎇
Browse files

fixed wrong dtype when use copy_empty

parent b6434892
No related branches found
No related tags found
No related merge requests found
...@@ -479,19 +479,23 @@ class DictOfSeries: ...@@ -479,19 +479,23 @@ class DictOfSeries:
return self.copy(deep=True) return self.copy(deep=True)
def copy(self, deep=True): def copy(self, deep=True):
if not deep: if deep:
return DictOfSeries(data=self._data, itype=self._itype, cast_policy=self._policy, fastpath=True) data = pd.Series(dtype='O', index=self.columns)
for c in self.columns:
new = DictOfSeries(itype=self.itype, columns=self.columns, cast_policy=self._policy, fastpath=True) data.at[c] = self._data.at[c].copy(deep=True)
for c in self.columns: else:
new._data.at[c] = self._data.at[c].copy(deep=True) data = self._data
return new kws = dict(itype=self._itype, cast_policy=self._policy)
return DictOfSeries(data=data, fastpath=True, **kws)
def copy_empty(self, columns=True): def copy_empty(self, columns=True):
return DictOfSeries(columns=self.columns if columns is True else None, # correct data = None
itype=self.itype, if columns is True: # is correct
cast_policy=self._policy, data = pd.Series(dtype='O', index=self.columns)
fastpath=True) 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): def __str__(self):
return self.__repr__() return self.__repr__()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment