#-*- coding: utf-8 -*-
import pandas as pd
inputfile = './electricity_data_analyze.xls'
outputfile = './electricity_data.xls'
data = pd.read_excel(inputfile)
data[u'线损率'] = data[u'线损率'].str.strip('%').astype(float)/100 #Series.astype()将对象类型转化为指定的类型
data.to_excel(outputfile, index=False)
百分数数据:

转化后的小数数据:

最后
以上就是阳光唇彩最近收集整理的关于Pandas列百分数转化为小数的全部内容,更多相关Pandas列百分数转化为小数内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复