How can I generate two-way table in Python?

python

#1

Hi,

I have 2+ years of experience in data analytics. Recently I have started learning python for data analysis. One of the issue I have encountered is “generate two-way or frequency table”. Please suggest the library name and related function.

It would be great help if you will suggest me the libraries to focus.

Thx,
Rahul


#2

@rahul

You can generate Frequency Tables using dataframe.groupby. Refer the below code:
Code

import pandas as pd
df=pd.read_excel("E:/First.xlsx", "Sheet1") 
print df
test= df.groupby(['Gender','BMI'])
test.size()

Output

You can also refer post on data exploration using python:

Hope this helps!

Regards,
Sunil