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
Hello ahmedakhokhar!
We believe that this post does not fit the main topic of this site.
This is not a bioinformatics question. Please note: This is your second time posting such a question.
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!