Category : decimal

may my English is not good enough to research this question on Google so i posted here please help For example: tax amount = 7.5%. In Python i have to define like this: tax_amount = .075 total_cost = purchase_amount*(1+tax_amount) When i try to use 0.075 instead of .075 and purchase_amount x tax_amount instead of purchase_amount ..

I have pandas column named Price_col. which look like this. Price_col 1. 1000000.000 2. 234556.678900 3. 2345.00 4. 5. 23.56 I am trying to add commas to my Price_col to look like this. Price_col 1. 1,000,000.000 2. 234,556.678900 3. 2,345.00 4. 5. 23.56 when I try convert the values it always round off. is there ..

I read that for precise in python I should use Decimal module, but when testing simple calculations I get values that is not that precise. Using python 3.7.12 >>> from decimal import Decimal as dc >>> dc(1.1)*dc(3) Decimal(‘3.300000000000000266453525910’) The result should be 3.3 Solution: >>> dc(‘1.1’)*dc(3) Decimal(‘3.3’) or >>> a = 1.1 >>> dc(str(a))*dc(3) Decimal(‘3.3’) ..

I have a pandas dataframe like this: df = pd.DataFrame([ {‘A’: ‘aaa’, ‘B’: 0.01, ‘C’: 0.00001, ‘D’: 0.00999999999476131, ‘E’: 0.00023191546403037534}, {‘A’: ‘bbb’, ‘B’: 0.01, ‘C’: 0.0001, ‘D’: 0.010000000000218279, ‘E’: 0.002981781316158273}, {‘A’: ‘ccc’, ‘B’: 0.1, ‘C’: 0.001, ‘D’: 0.0999999999999659, ‘E’: 0.020048115477145148}, {‘A’: ‘ddd’, ‘B’: 0.01, ‘C’: 0.01, ‘D’: 0.019999999999999574, ‘E’: 0.397456279809221}, {‘A’: ‘eee’, ‘B’: 0.00001, ‘C’: ..

I have a list of lists ListOFlist=[[010100100110010101101110],[011001000110010101111010]] …etc I want to convert them to decimal Listoflist=[5399918,6579578]…etc and then for each digit of the list , apply this formula 5399918*x[p] and put them in a newlist Newlist=[5399918*x[p],6579578*x[p]]etc… Source: Python..

I’m new to pybind11, want to detect if a py::object isinstance of python’s decimal.Decimal. How could I write it in C++ pybind11 module ? Source: Python-3x..

I’m new to pybind11, want to detect if a py::object isinstance of python’s decimal.Decimal. How could I write it in C++ pybind11 module ? Source: Python-3x..