I am trying to do a pivot in python using pandas pivot_table. When I am aggregating a column with huge(more than 10 digits with 3-4 numbers beyond decimals point) floating-point numbers using both "np.sum" and just "sum", getting wrong results. Below sharing an example.
data = pd.DataFrame({"store":["A","B","C","D"],
"sales":[11046021.3675,9222589.4978,3851017.2855,8284985.4983],
"place":["P","P","Q","Q"]})
code1 = pd.pivot_table(data,index="place",aggfunc={"sales":"sum"})
code2 = pd.pivot_table(data,index="place",aggfunc={"sales":np.sum})
Ideally, we should get sum of "P" as 20268610.8653 but with the above codes, it comes out 20268600. Does anyone know what is wrong here and can anyone please guide me on how to resolve the above discrepancy?