From 029aef2ee231abe44b4300e16801ca4941481ef1 Mon Sep 17 00:00:00 2001 From: Bert Palm <bert.palm@ufz.de> Date: Fri, 21 Feb 2020 13:45:17 +0100 Subject: [PATCH] fixedes --- dios/dios.py | 6 +++++- dios/locator.py | 5 +++-- profiling/performance.py | 21 ++++++++++----------- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/dios/dios.py b/dios/dios.py index b83358e..4c7d308 100644 --- a/dios/dios.py +++ b/dios/dios.py @@ -405,7 +405,11 @@ class DictOfSeries: def squeeze(self, axis=None): if axis in [0, 'index']: raise NotImplementedError - elif axis in [1, 'columns']: + + if len(self) > 1: + return self + + if axis in [1, 'columns']: return self._data.squeeze() elif axis is None: return self._data.squeeze().squeeze() diff --git a/dios/locator.py b/dios/locator.py index ac7cbdc..cb2f8b4 100644 --- a/dios/locator.py +++ b/dios/locator.py @@ -108,13 +108,14 @@ class _iLocIndexer(_Indexer): # we do use loc instead of iloc as we get real keys. # this works, because keys keep sorted if they come # from an series-index (doesn't work with df-index) - ser = self._data[key] + ser = self._data.loc[key] if ixalign: ix = ser.index.intersection(ix.index) if isinstance(right, pd.Series): left = ser[ix] right, ix = align_index_by_policy(left, right) ser.iloc[ix] = right + self._data.loc[key] = ser def _get_item(self, key, ix, ixalign=False): ser = self._data.loc[key] @@ -148,7 +149,7 @@ def _unpack_value(keys, ix, val): # prepare value val = list(val) if is_iterator(val) else val - val = val.squeeze() if is_dios_like(val) else val + val = val.squeeze(axis=1) if is_dios_like(val) else val dioslike, nlistlike = is_dios_like(val), is_nested_list_like(val) # check value diff --git a/profiling/performance.py b/profiling/performance.py index 1be82e8..de2e58a 100644 --- a/profiling/performance.py +++ b/profiling/performance.py @@ -63,12 +63,12 @@ def b_timings(df, t0, t1, v1, v2): def dios_timings(dios, t0, t1, v1, v2): _t0 = time.time() - a = dios[t0:t1, :] + a = dios.loc[t0:t1, :] _t1 = time.time() - b = dios[:, v1] + b = dios.loc[:, v1] _t2 = time.time() if profile_assignment: - dios[t0:t1, v1] = dios[t0:t1, v1] * 1111 + dios.loc[t0:t1, v1] = dios.loc[t0:t1, v1] * 1111 _t3 = time.time() timingsdf.at[rows, ('ts', 'dios')] += _t1 - _t0 @@ -76,7 +76,6 @@ def dios_timings(dios, t0, t1, v1, v2): timingsdf.at[rows, ('ass', 'dios')] += _t3 - _t2 return a, b, dios - def gen_random_timestamps(m, M): r = (M - m) * (np.random.randint(10,90) + np.random.random()) * 0.01 a , b = m + r, M - r @@ -106,22 +105,22 @@ if __name__ == '__main__': # max increase of of rows # 1 = 10 # 2 = 100 # .... # 5 = 100'000 - iterations = 4 - runs = 10 + iterations = 5 + runs = 1 cols = 10 profile_assignment = True # which to calc and plot - use_df = True - use_a = False - use_b = False + use_df = False + use_a = True + use_b = True use_dios = True # plot options - normalize_to_df = False + normalize_to_df = True plot_xlog = True - plot_ylog = False + plot_ylog = True # ######################## -- GitLab