I have a data frame as
ent_id buy new_perc_buy sell new_perc_sell
123 0.116211962 0.116198415 0.496314325 0.496256466
124 0.007214061 0.00721322 0.153933545 0.1539156
125 0.003410283 0.003409886 0.499973272 0.499914987
126 0.231587543 0.231560545 0.699696021 0.699614452
127 0.056794334 0.056787713 0.235372057 0.235344618
128 0.130377754 0.130362555 0.187575903 0.187554036
129 0.998294858 0.99817848 0.917661563 0.917554585
130 0.208247701 0.208223424 0.575032323 0.574965287
now I have to match buy with new_perc_buy (upto 5 decimal places) similarly sell with new_perc_sell (upto 5 decimal places) with correspond to ent_id and if it does not meet the decided condition it fails
as I am using numpy.testing.assert_almost_equal
import numpy
numpy.testing.assert_almost_equal(df_ss['rnk_perc_buy'],df_ss['new_perc_rnk_perc_buy'], decimal=5, err_msg='false', verbose=True)
I am getting this error
ValueError Traceback (most recent call last)
in () 1 import numpy ----> 2 numpy.testing.assert_almost_equal(df_ss['rnk_perc_buy'],df_ss['new_perc_rnk_perc_buy'], decimal=5, err_msg='false', verbose=True) 3 # df_ss.head(10)
C:\Program Files\Anaconda3\lib\site-packages\numpy\testing_private\utils.py in assert_almost_equal(actual, desired, decimal, err_msg, verbose) 588 # check that both are nan if any is a nan, and test for equality 589 # otherwise --> 590 if not (gisfinite(desired) and gisfinite(actual)): 591 if gisnan(desired) or gisnan(actual): 592 if not (gisnan(desired) and gisnan(actual)):
C:\Program Files\Anaconda3\lib\site-packages\pandas\core\generic.py in nonzero(self) 1477 def nonzero(self): 1478 raise ValueError( -> 1479 f"The truth value of a {type(self).name} is ambiguous. " 1480 "Use a.empty, a.bool(), a.item(), a.any() or a.all()." 1481 )
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
also there any way by which I get error output like below
AssertionError:
Arrays are not almost equal to 5 decimals for **ent_id 123**
ACTUAL: 0.116211962
DESIRED: 0.116198415
Aucun commentaire:
Enregistrer un commentaire