on-internet
← Community

AttributeError: 'str' object has no attribute 'cat'

Stack Overflow ·

For each GENE_SYMBOLS column of a dataframe, merge the rows and retain only unique comma-separated or dash-separated values. After merging the values of each row into a list, obtain only the unique values. geneset = pd.read_csv("genesets.v2023.1.Hs.tsv", sep="\t", index_col=0) geneset = geneset.loc["GENE_SYMBOLS"] # retrieve only rows with index name "GENE_SYMBOLS" for i in geneset.columns: genes = i.cat(sep=',').tolist() # Merge all the rows of strings with "," delimiter and store as a list genes = genes.split(",") # split by the "," delimiter genes = genes.split("-") # or the "-" delimiter g

Comments

Sign in or sign up to comment and upvote.

No comments yet.