detour via numpy array unified datatype

This commit is contained in:
Martin Diehl 2020-01-15 14:15:57 +01:00
parent d66b05134d
commit dd70b38d46
1 changed files with 7 additions and 3 deletions

View File

@ -14,8 +14,8 @@ class Table():
Parameters Parameters
---------- ----------
data : numpy.ndarray data : numpy.ndarray or pandas.DataFrame
Data. Data. Column labels from a pandas.DataFrame will be replaced.
shapes : dict with str:tuple pairs shapes : dict with str:tuple pairs
Shapes of the columns. Example 'F':(3,3) for a deformation gradient. Shapes of the columns. Example 'F':(3,3) for a deformation gradient.
comments : iterable of str, optional comments : iterable of str, optional
@ -23,6 +23,10 @@ class Table():
""" """
self.comments = [] if comments is None else [c for c in comments] 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.data = pd.DataFrame(data=data)
self.shapes = shapes self.shapes = shapes
self.__label_condensed() self.__label_condensed()
@ -95,7 +99,7 @@ class Table():
else: else:
shapes[label] = (1,) 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) return Table(data,shapes,comments)