I have a dataset that has numerical values, empty values and text values. I want to do the following in pandas:
- Numerical Values -> Float
- Empty Values -> N/A
- Text Values -> N/A
When I try to run astype('float')
, I get an error:
import pandas as pd
data = ['5', '4', '3', '', 'NO DATA ', '5']
data = ['5', '4', '3', '', '', '5']
df = pd.DataFrame({'data': data})
df[['data']].astype('float')
I've tried to look over the documentation and stackoverflow, but I didn't find out how to do this.