I have a dataframe selected from a sql table that looks like this:
id shares_float
0 1 621.76M
1 2 329.51M
in another word,
[(1, '621.76M'), (2, '329.51M')]
I want to split share_float so that if it is “B”, multiply 1,000,000,000, and if it is “M”, multiply 1,000,000, and if it is not or does not have a trailing character, just convert and assign the number.
The result should be a float type.
ticker_id shares_float float_value
0 1 621.76M 621760000.00
1 2 3.51B 3510000000.00
I am new to pandas. Is there any way to do this in pandas? or do I need to convert the data to a list and do my manipulations in a loop and then convert it back to a pandas DataFrame?
Note added: The answer works great! Thank. By the way, how does this feature work?