Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
221 views
in Technique[技术] by (71.8m points)

python - Groupby for diffrent dummy variables

I have a dataset that has individual level data (so each row is one individual) for cancer patients from 2006 to 2016 for 54 counties in California. I generated a cancer count (of 1) for each row to eventually sum up the cancer incidences by county and year for each demographics. I generated dummy variables for my categorical variables, but don't know how to proceed from there.I have tried to grouby, but it's only giving me a combination of all the demographics (for example, I want all male patients in 2008 in county_x but I get white male patients that are in the age range_x instead) This is my dataset right now:

ID # Year County Sex_1 Race_2 Race_3 age_range_2 age_range_3 age_range_4 cancer_count
324 2008 CC 1 0 0 0 0 0 1
325 2008 CC 1 0 1 0 0 1 1
326 2010 AL 1 0 0 1 0 0 1
327 2015 Y 1 0 0 0 0 0 1
328 2008 AL 0 0 0 0 0 0 1
question from:https://stackoverflow.com/questions/66054501/groupby-for-diffrent-dummy-variables

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...