This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Some Questions About Python model -- pandas frame and function apply

Hi all

I have a question about data operation.

I have a file:

a      100
a      20
b      40
c      30
a      60
a      70

I want to obtain the result:

a      60(the average of 100 and 20)
b      40
c      30
d      65the average of 60 and 70)

the process can be described as computing the average value of col2 based on index col1.

I have shell code, but I don't know how to convert to python code.

cat 1.txt |awk -F"," '{sum[$1]+=$2}END{for(c in sum){print c,sum[c]}}'

Any help would be greatly appreciated.

sequencing rna-seq python code

Hello Ashley!

We believe that this post does not fit the main topic of this site.

Off topic post, not related to bioinformatics

For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.

If you disagree please tell us why in a reply below, we'll be happy to talk about it.

Cheers!

1 answer

The answer is

df.groupby([’xxxx’]).mean()

Log in to answer this question.