Is a numeric index valid for a feature table?

When loading a pandas data frame into a FeatureTable[Frequency] if the index is numeric values an error is returned

df = pd.DataFrame([[1, 2], [2, 3]], columns=['ATG', 'ACG'])
qiime.Artifact.import_data(FeatureTable[Frequency], df)


AttributeError: 'int' object has no attribute 'encode'

Is this the intended behavior? If not I can post an issue to the issue tracker, if it is intended would a better error message be useful?

Thanks

2 Likes

@John_Chase, at this point we only support strings as indices. I think this makes sense, as it makes the type more predictable, but I don’t think it’s an essential part of the design. Is this functionality that is important for your application? (Note that you can of course cast your indices from ints to strings.)

1 Like

We are often grouping or combining samples in tables. If we collapse samples based on a category with numeric labels the resulting table will have a numeric index, this is somewhat unavoidable. We have been converting the indices to strings which is really not a problem to do. I just wasn’t sure if that behavior was intended. Also the first time we saw that error it took a while to track down what the cause was, which is why I thought a different error message may be useful.

1 Like

Thanks @John_Chase. Completely agree about having a better error message. I created an issue for that.

1 Like

Thanks @gregcaporaso!

1 Like

A more descriptive error message was merged into q2-types, thanks @John_Chase!