From dd70b38d468d7a83dded09fa7bf072af7cc5301b Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 15 Jan 2020 14:15:57 +0100 Subject: [PATCH] detour via numpy array unified datatype --- python/damask/table.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/python/damask/table.py b/python/damask/table.py index c732456b6..02c1e6e5c 100644 --- a/python/damask/table.py +++ b/python/damask/table.py @@ -14,8 +14,8 @@ class Table(): Parameters ---------- - data : numpy.ndarray - Data. + data : numpy.ndarray or pandas.DataFrame + Data. Column labels from a pandas.DataFrame will be replaced. shapes : dict with str:tuple pairs Shapes of the columns. Example 'F':(3,3) for a deformation gradient. comments : iterable of str, optional @@ -23,6 +23,10 @@ class Table(): """ self.comments = [] if comments is None else [c for c in comments] + try: + self.data = data + self.data.columns = [''] * len(self.data.columns) + except: self.data = pd.DataFrame(data=data) self.shapes = shapes self.__label_condensed() @@ -95,7 +99,7 @@ class Table(): else: shapes[label] = (1,) - data = pd.read_csv(f,names=list(range(len(labels))),sep=r'\s+').to_numpy() + data = pd.read_csv(f,names=list(range(len(labels))),sep=r'\s+') return Table(data,shapes,comments)