我是靠谱客的博主 阳光唇彩,这篇文章主要介绍Pandas列百分数转化为小数,现在分享给大家,希望可以做个参考。

#-*- 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列百分数转化为小数内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(123)

评论列表共有 0 条评论

立即
投稿
返回
顶部