aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThéo de la Hogue2022-05-20 11:08:20 +0200
committerThéo de la Hogue2022-05-20 11:08:20 +0200
commit23cee9eae4e023a3374ea26ad11940aebe92594f (patch)
tree0b3e5e4b0ba2de001a27c0094926619c51b63960 /src
parent3176cb6fb4ac47a5bccd2aa2f1b8eab3a5594853 (diff)
downloadargaze-23cee9eae4e023a3374ea26ad11940aebe92594f.zip
argaze-23cee9eae4e023a3374ea26ad11940aebe92594f.tar.gz
argaze-23cee9eae4e023a3374ea26ad11940aebe92594f.tar.bz2
argaze-23cee9eae4e023a3374ea26ad11940aebe92594f.tar.xz
Removing DictObject class.
Diffstat (limited to 'src')
-rw-r--r--src/argaze/DataStructures.py32
1 files changed, 6 insertions, 26 deletions
diff --git a/src/argaze/DataStructures.py b/src/argaze/DataStructures.py
index 8517378..ead5c48 100644
--- a/src/argaze/DataStructures.py
+++ b/src/argaze/DataStructures.py
@@ -5,31 +5,6 @@ import json
import bisect
import pandas
-class DictObject():
- """Convert dictionnary into object"""
-
- def __init__(self, object_type = str, **dictionnary):
- self.__dict__.update(dictionnary)
- self.__type = object_type
-
- def __getitem__(self, key):
- return self.__dict__[key]
-
- def __str__(self):
- return json.dumps({key: self.__dict__[key] for key in self.__dict__.keys()}, default = vars)
-
- def get_type(self):
- return self.__type
-
- def keys(self):
- return list(self.__dict__.keys())[:-1]
-
- def append(self, key, value):
- __type_key = list(self.__dict__.keys())[-1]
- __type_value = self.__dict__.pop(__type_key)
- self.__dict__.update({key:value})
- self.__dict__[__type_key] = __type_value
-
class TimeStampedBuffer(collections.OrderedDict):
"""Ordered dictionary to handle timestamped data.
```
@@ -107,11 +82,16 @@ class TimeStampedBuffer(collections.OrderedDict):
except:
raise RuntimeError(f'Can\' write {filepath}')
- def as_dataframe(self, exclude=[]):
+ def as_dataframe(self, exclude=[], split={}):
"""Convert buffer as pandas dataframe."""
df = pandas.DataFrame.from_dict(self.values())
df.drop(exclude, inplace=True, axis=True)
+
+ for key, columns in split.items():
+ df[columns] = pandas.DataFrame(df[key].tolist(), index=df.index)
+ df.drop(key, inplace=True, axis=True)
+
df['timestamp'] = self.keys()
df.set_index('timestamp', inplace=True)