I have the following dataframe:
df2 = pd.DataFrame({'price': [Decimal(1.4334), Decimal(1.4335), Decimal(1.4336), Decimal(1.4337)], 'tpo_count': [1, 2, 3, 1], 'tpo': ['A', 'BC', 'BCD', 'D']})
print(df2.dtypes)
price object
tpo_count int64
tpo object
dtype: object
If want ot create an additional column named "price_float" which is the same column as "price" but with floats (to be later draw using matplotlib which does not support Decimal).
I have tried:
df2['price_float']=float(df2['price'])
but I get:
TypeError: cannot convert the series to <class 'float'>
df2['price_float'] = df2['price_float'].astype(float). Did you actually try researching how to change types?