diff --git a/dios/dios.py b/dios/dios.py index 74ecaf463b8191e8ae502a32e1b3bf327a626ed2..f907d1caa1cfbcc697b261326683e5bd068c11cd 100644 --- a/dios/dios.py +++ b/dios/dios.py @@ -243,10 +243,9 @@ class DictOfSeries: def _setitem_dios(self, data, value): keys = self.columns.intersection(data.columns) for k in keys: - l = self._data.at[k] r = value[k] - idx = l.index.intersection(r.index) - l[idx] = r[idx] + idx = data._data.at[k].index.intersection(r.index) + self._data.at[k][idx] = r[idx] @property def loc(self): diff --git a/dios/locator.py b/dios/locator.py index 651334b1d63d54de87142f0f4f841b5f93944185..f42d3e15ab04bf0baf960230b6fe0d18bff458ba 100644 --- a/dios/locator.py +++ b/dios/locator.py @@ -55,7 +55,8 @@ class _LocIndexer(_Indexer): data = self._data.loc[colkey].copy() - # .loc[any, scalar] + # .loc[any, scalar] -> (a single) series + # .loc[scalar, scalar] -> (a single) value if _is_hashable(colkey): new = data.loc[rowkey] @@ -63,8 +64,12 @@ class _LocIndexer(_Indexer): else: for k in data.index: data.at[k] = data.at[k].loc[rowkey] + + # .loc[scalar, non-scalar] -> column-indexed series if _is_hashable(rowkey): new = data + + # .loc[non-scalar, non-scalar] -> dios else: new = self._dios.copy_empty(columns=False) new._data = data @@ -106,16 +111,21 @@ class _iLocIndexer(_Indexer): data = self._data.iloc[colkey].copy() - # .iloc[any, scalar] + # .iloc[any, int] -> single series + # .iloc[int, int] -> single value if _is_integer(colkey): new = data.iloc[rowkey] - # .iloc[any, non-scalar] + # .iloc[any, non-int] else: for k in data.index: data.at[k] = data.at[k].iloc[rowkey] + + # .iloc[int, non-int] -> column-indexed series if _is_integer(rowkey): new = data + + # .iloc[non-int, non-int] -> dios else: new = self._dios.copy_empty(columns=False) new._data = data @@ -127,11 +137,11 @@ class _iLocIndexer(_Indexer): if _is_dios_like(rowkey) or _is_dios_like(colkey): raise ValueError("Cannot index with multidimensional key") - # .iloc[any, scalar] + # .iloc[any, int] if _is_integer(colkey): self._data.iat[colkey].iloc[rowkey] = value - # .iloc[any, non-scalar] + # .iloc[any, non-int] else: for s in self._data.iloc[colkey]: s.iloc[rowkey] = value @@ -211,7 +221,7 @@ class _aLocIndexer(_Indexer): for i, c in enumerate(colkeys): l = self._data.at[c] r = value[c] - idx = l.index.intersection(r.index) + idx = l.loc[rowkeys[i]].index.intersection(r.index) l[idx] = r[idx] # row align - align given series to every series in ourself