在Python中将对象转换为str的问题

时间:2019-07-17 23:18:49

标签: python pandas dtype

我需要将对象转换为字符串

import pandas as pd
import locale
import numpy as np

df_csv = pd.read_csv('df_empenho.csv', sep=';', encoding='utf-8')

df_csv['valor2'] = df_csv['Empenhado'].astype(str)

df_csv['valor2'].astype(str).apply(lambda x : x.replace('.',''))

df_csv['valor2'].head()

输出

0    13.188,15
1     8.492,40
2     3.570,00
3     1.486,20
4     2.660,67

Name: valor2, dtype: object

我希望dtype = string

0 个答案:

没有答案