我一直在尝试将巴西货币线转换为浮动值
import pandas as pd
df = pd.read_csv (r'OfficialDataSet.csv', dtype={'Income': str})
df['Income'].apply(type).value_counts()
df['Income'] = df['Income'].str.replace(',','').str.replace('R$ ','').astype('float')
但我一直在犯这样的错误:
ValueError: could not convert string to float: 'R$ 374.30'
如果您有任何建议,我将不胜感激
您走的是正确的道路,只需要一点零钱-在$前面加一个\就行了:
或者你可以这样做:
相关问题 更多 >
编程相关推荐