Using the PANDAS, I want to arrive at the preference of two different groups. eg: Male and Female client visiting the hospital from a CSV file.
I have arrived at the counts by group by. I'm stuck at the below two scenarios:
- If I need to filter only by male or female and the count by the hospital.
- If I need to remove particular row values (exclude a particular hospital)
Coding part
import pandas as pd
enter code here`df = pd.read_csv("EDdata.csv", index_col = "Case")
df.groupby(['Hospital_Name','Gender'])['Gender'].count()
Result:
Hospital_Name Gender Count
AH F 667
M 1433
CGH F 2763
M 4301
KKH F 3466
M 4431
KTPH F 2116
M 3886