Wednesday, 15 February 2012

python - pandas dataframe count uniques with respect to another column -


I have a datafree that looks like the following

  category subcategory contract week 1 Week 2 Weeks 3 Kat 1 All 1 11001 20 20 10 Cat 1 All 1 11001 0 30 Cat 1 All 2 11002 10 20 0 Cat 1 All 2 11003 10 20 0 CATAL 2 All 3 11004 10 0 50 CAT 2 All 3 11005 10 20 0  

I would like to count the number of countless contracts for each week which is in accordance with non-zero category and subcategory in the week.

  category | Subcategory | Week 1 Week 2 Week 3 || ----------------------------------------------- Cat 1 | All 1 1 | 1 | 1 | Cat 1 | All 2 2 | 2 | 0 | Cat 2 Sub 3 2 | 1 | 1 |  

I am trying to make a toy example for this but it is new with pandals, so I am also struggling there.

No comments:

Post a Comment