biocore / biom-format

The Biological Observation Matrix (BIOM) Format Project
http://biom-format.org
Other
89 stars 95 forks source link

From dataframe #972

Open mortonjt opened 2 months ago

mortonjt commented 2 months ago

One of the most common conversions to biom tables is from pandas data frames. Thus, having a Table.from_dataframe command would be a strong utility. As a first pass, the following can be done

@staticmethod
def from_dataframe(self, df):
    """ pd.DataFrame with rows as samples and features as columns. """
    return biom.Table(df.values.T, df.columns, df.index)

I find myself copying / pasting this command quite often. So having this embedded within biom would be low hanging fruit, but slightly ease analysis effort.