adjusted data.column retrieval in save method

This commit is contained in:
Daniel Otto de Mentock 2022-01-13 17:15:54 +01:00
parent b4088b666e
commit db21e82fe3
1 changed files with 7 additions and 5 deletions

View File

@ -1,7 +1,7 @@
import re import re
import copy import copy
import pathlib import pathlib
from typing import Union, Optional, Tuple, List, TextIO, Set from typing import Union, Optional, Tuple, List, TextIO
from _io import TextIOWrapper from _io import TextIOWrapper
import pandas as pd import pandas as pd
@ -9,7 +9,6 @@ import numpy as np
from . import util from . import util
class Table: class Table:
"""Manipulate multi-dimensional spreadsheet-like data.""" """Manipulate multi-dimensional spreadsheet-like data."""
@ -372,7 +371,7 @@ class Table:
""" """
dup = self.copy() dup = self.copy()
dup._add_comment(label, data.shape[1:],info) dup._add_comment(label, data.shape[1:], info)
m = re.match(r'(.*)\[((\d+,)*(\d+))\]',label) m = re.match(r'(.*)\[((\d+,)*(\d+))\]',label)
if m: if m:
key = m.group(1) key = m.group(1)
@ -559,9 +558,12 @@ class Table:
Filename or file for writing. Filename or file for writing.
""" """
seen: Set = set() data_column_items = []
for col in self.data.columns:
if col not in data_column_items:
data_column_items.append(col)
labels = [] labels = []
for l in [x for x in self.data.columns if x not in seen]: for l in data_column_items:
if self.shapes[l] == (1,): if self.shapes[l] == (1,):
labels.append(f'{l}') labels.append(f'{l}')
elif len(self.shapes[l]) == 1: elif len(self.shapes[l]) == 1: