fixing issues
This commit is contained in:
@@ -1648,7 +1648,7 @@ def read_data(columns, ids=[], doclean=True, workstrokesonly=True, debug=False,
|
||||
datadf = pl.concat(data)
|
||||
existing_columns = [col for col in columns if col in datadf.columns]
|
||||
datadf = datadf.select(existing_columns)
|
||||
except (ShapeError, SchemaError):
|
||||
except ShapeError:
|
||||
try:
|
||||
data = [
|
||||
df.select(columns)
|
||||
@@ -1703,7 +1703,61 @@ def read_data(columns, ids=[], doclean=True, workstrokesonly=True, debug=False,
|
||||
datadf = pl.concat(data)
|
||||
except ShapeError:
|
||||
return pl.DataFrame()
|
||||
except SchemaError:
|
||||
try:
|
||||
data = [
|
||||
df.select(columns)
|
||||
for df in data]
|
||||
except ColumnNotFoundError:
|
||||
existing_columns = [col for col in columns if col in df.columns]
|
||||
df = df.select(existing_columns)
|
||||
|
||||
# float columns
|
||||
floatcolumns = []
|
||||
intcolumns = []
|
||||
stringcolumns = []
|
||||
for c in columns:
|
||||
try:
|
||||
if metricsdicts[c]['numtype'] == 'float':
|
||||
floatcolumns.append(c)
|
||||
if metricsdicts[c]['numtype'] == 'integer':
|
||||
intcolumns.append(c)
|
||||
except KeyError:
|
||||
if c[0] == 'f':
|
||||
stringcolumns.append(c)
|
||||
else:
|
||||
intcolumns.append(c)
|
||||
|
||||
try:
|
||||
data = [
|
||||
df.with_columns(
|
||||
cs.float().cast(pl.Float64)
|
||||
).with_columns(
|
||||
cs.integer().cast(pl.Int64)
|
||||
).with_columns(
|
||||
cs.by_name(intcolumns).cast(pl.Int64)
|
||||
).with_columns(
|
||||
cs.by_name(floatcolumns).cast(pl.Float64)
|
||||
).with_columns(
|
||||
cs.by_name(stringcolumns).cast(pl.String)
|
||||
)
|
||||
for df in data
|
||||
]
|
||||
except ComputeError:
|
||||
pass
|
||||
except ColumnNotFoundError:
|
||||
pass
|
||||
|
||||
try:
|
||||
datadf = pl.concat(data)
|
||||
except SchemaError:
|
||||
try:
|
||||
data = [
|
||||
df.with_columns(cs.integer().cast(pl.Float64)) for df in data
|
||||
]
|
||||
datadf = pl.concat(data)
|
||||
except ShapeError:
|
||||
return pl.DataFrame()
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user