I have data calls SalesData that's contains "Profit", "Sales" and "Sub-Category" and when I use this code
SubCategoryProfit = SalesData[["Sub-Category", "Profit"]].groupby(by = "Sub-Category").sum().sort_values(by = "Profit")
#Print the results
SalesData.style.applymap(color_negative_red, subset=['Profit','Sales'])
print(SubCategoryProfit)
I will get these results
Profit
Sub-Category
Tables -17725.4811
Bookcases -3472.5560
Supplies -1189.0995
Fasteners 949.5182
Machines 3384.7569
Labels 5546.2540
Art 6527.7870
Envelopes 6964.1767
however when I am looking for the negative results only with this code
JustSubCatProf = SalesData[["Sub-Category", "Profit"]]
NegProfFilter = SalesData["Profit"] < 0.0
JustNegSubCatProf = JustSubCatProf[NegProfFilter].groupby(by = "Sub-Category").sum().sort_values(by = "Profit")
print(JustNegSubCatProf)
I will get this!
Profit
Sub-Category
Binders -38510.4964
Tables -32412.1483
Machines -30118.6682
Bookcases -12152.2060
Chairs -9880.8413
Appliances -8629.6412
Phones -7530.6235
Furnishings -6490.9134
Storage -6426.3038
Supplies -3015.6219
There should be only 3 negative results I'm not sure what I am doing wrong. Can someone help me please?