-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
For example:
result = db.fetch_data_table('Baliunas1995', ['S_mean', 'activity_class', 'Pcyc', 'Pcyc2'], meta={'Pcyc':'FAPGrade'}, nulls=Truehas a dtype:
[('star', 'S12'), ('S_mean', '<f8'), ('activity_class', 'S12'), ('Pcyc', 'O'), ('Pcyc2', 'O'), ('FAPGrade', 'O')]Which causes all sorts of problems when trying to plot, for example. The ugly workaround is to cast the column post-fetch:
print result.dtype
for i, col in enumerate(result.colnames):
if col in ('Pcyc', 'Pcyc2'):
dtype[i] = 'float64'
result[col].fill_value = np.nan
result[col] = result[col].astype('float64')
if col in ('FAPGrade'):
dtype[i] = 'S'
result[col].mask = [x is None for x in result[col]]
result = astropy.table.Table(result, dtype=dtype)
for col in ('Pcyc', 'Pcyc2'):
result[col].mask = np.isnan(result[col])
print "Final:", result.dtypeThis needs to be handled in fetchall_astropy()
Metadata
Metadata
Assignees
Labels
No labels