0

I have a data in excel file. here is a sample data and image.

In[1] import pandas as pd
df = pd.DataFrame({'T1': ['A', 'B', 'A'], 
                   'T1_data': [3, 2, '3K'],
                  'T2': ['B', 'A', 'B'], 
                   'T2_data': ["5,2K", 4, 2],
                  
                  })
df

Out[1]  T1  T1_data   T2    T2_data
    0   A     3       B      5,2K
    1   B     2       A       4
    2   A     3K      B       2

expected outputs :

i want this

  T1_count   T1_count  T2_count  T2_data
    
A   2         3, 3k        1       4

B   1          2           2      5, 2k

and this

    T12_count    T12_data
    
A      3         3, 3K, 4

B      3         2, 5, 2.

I know simple value_counts() but i don't know how can i do above things. if anyone can help it would be really appriciated.

df1 = df['T1'].value_counts()
df1

A    2
B    1
Name: T1, dtype: int64
The Flain
  • 41
  • 4
  • 1
    Please provide your sample input and output in the text of your question, not as a picture or link. See [How to make good pandas examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples). PLease also include a [mcve] with _code_ for what you've tried so far, and what went wrong with your attempt(s) – G. Anderson Nov 17 '20 at 19:39
  • 1
    Thank you for sharing links. i have changed question accordingly. @G.Anderson – The Flain Nov 18 '20 at 12:00

0 Answers0