Off topic:data file format
1
0
Entering edit mode
7.9 years ago
ahmedakhokhar ▴ 150

I am working with a tab separated files:

A    B    C   D

a    d    ii  domain 

a    d    g domain

a    h     g domain

a     i     k motif

c     i      k motif

c     g     ii motif

v     g      p domain

Question: I want to count each entry in first column and all related entry to it in second, third and fourth column like:

a 4 d 2 h 1 i 1 ii 1 k 1 domain 3 motif 1

c 2 i 1 g 1 k 1 ii 1 motif 2 

v 1 g 1 p 1 motif 1

I am trying to sort this data with python pandas by these commands:

df = pd.read_csv('file.txt', delimiter= '\t', names = ['A', 'B', 'C', 'D']) 

df1.groupby(['a', 'c', 'd', 'e']).count()

but it does not return the desired results.

Any help would be appreciated, thanks.

pandas python • 1.4k views
ADD COMMENT
This thread is not open. No new answers may be added
Traffic: 2609 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