Off topic:Some Questions About Python model -- pandas frame and function apply
1
0
Entering edit mode
4.7 years ago
Ashley ▴ 90

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 • 384 views
ADD COMMENT
This thread is not open. No new answers may be added
Traffic: 3115 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6