I need to convert list to float, and divide the number of the floats. It is returning this error:
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/Users/user/Desktop/MESA /main.py", line 14, in <module>
IndonesiaCompany().calculate_the_percentage_of_shareholding_of_shareholders(df)
File "/Users/user/Desktop/MESA /clean.py", line 31, in calculate_the_percentage_of_shareholding_of_shareholders
shareholdings_as_percentages = [round(float(shareholding) / number_of_shares_in_paid_up_capital * 100) for shareholding in shareholders_number_of_shares]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/user/Desktop/MESA /clean.py", line 31, in <listcomp>
shareholdings_as_percentages = [round(float(shareholding) / number_of_shares_in_paid_up_capital * 100) for shareholding in shareholders_number_of_shares]
The codes that I have is as follows:
def calculate_the_percentage_of_shareholding_of_shareholders(self, df):
shareholders_number_of_shares: List = self.extract_shareholders_number_of_shares(df)
number_of_shares_in_paid_up_capital= self.extract_paid_up_capital()
shareholdings_as_percentages = [round(float(shareholding) / number_of_shares_in_paid_up_capital * 100) for shareholding in shareholders_number_of_shares]
return shareholdings_as_percentages
Is there any method to convert the above list to float and to solve the error?