如果可能的话,最好使用
read_csv:
df = pd.read_csv(file, thousands='.', decimal=',')
如果不可能,那么
replace应该有所帮助:
df['col2'] = (df['col2'].replace('.','', regex=True) .replace(',','.', regex=True) .astype(float))
如果可能的话,最好使用
read_csv:
df = pd.read_csv(file, thousands='.', decimal=',')
如果不可能,那么
replace应该有所帮助:
df['col2'] = (df['col2'].replace('.','', regex=True) .replace(',','.', regex=True) .astype(float))