WHat better syntax can I use for the operation below? Column A has variables containing 2 different SI units with different conversion methods: in KB as well MB. So, I want to do the following actions on the column which is in a pandas dataframe: data = pd.dataframe({"sizes":[12mb, 7kb, 17kb, 11mn], "song-type":["karaoke", "rock", "jazz", "rap"]}, index = [1,2,3,4])
I want to extract the numerics from size and multiply each numeric component of the variables having 'mb' with 1000. Then have the results in int or float format
if 'M' in x:
extract the numerics in x
convert to float
and assign x to (x * by 1000)
elif 'K' in x:
extract the numerics in x and convert to float
and assign it to x
else:
extract the numerics in x and convert to float
and assign it to x