Python的excel处理操作
python的excel处理操作
本文教程操作环境:windows7系统、Python3.9.1,DELLG3电脑。
创建excel在桌面
importpandasaspd
df=pd.DataFrame()
df.to_excel('C:/Users/Administrator/Desktop/output.xlsx')
print("done!")
注意要建立pipinstallopenpyxl包
读取excel
board=pd.read_excel('C:/Users/Administrator/Desktop/data.xlsx',
engine='openpyxl')
print(board.shape)
print(board)
画图
importmatplotlib.pyplotasplt
board.plot.line(x='省份',y='死亡')
plt.show()
花式绘图
board.plot.bar(x='省份',y=['死亡','现有确诊'],color=['orange','red'])
plt.show()
以上就是Python的excel几种常规处理操作,快点尝试看看吧~更多Python学习教程请关注IT培训机构:千锋教育。

相关推荐HOT
更多>>
python如何进行类型转换的
python提供了将变量或值从一种类型转换成另一种类型的内置函数。1、int:将符合数学格式数字型字符串转换成整数。>>>int('123')1232、s...详情>>
2023-11-07 18:51:20
python怎么生成随机数
以下实例演示了python如何生成一个随机数:#生成0~9之间的随机数#导入random(随机数)模块importrandomprint(random.randint(0,9))执行以上代码...详情>>
2023-11-07 17:09:17
python如何删除空格
python中的字符串方法提供了如下常用的方法来删除空白:strip():删除字符串前后的空白。lstrip():删除字符串前面(左边)的空白。rstrip():删...详情>>
2023-11-07 14:57:44
python怎么调用实例方法
在Python的类体中定义的方法默认都是实例方法,也示范了通过对象来调用实例方法。但要提醒大家的是,Python的类在很大程度上可看做是一个独立的...详情>>
2023-11-07 14:17:57