Pyhton 处理 excel 文档
source link: https://yjalifebook.com/pyhton-%e5%a4%84%e7%90%86-excel-%e6%96%87%e6%a1%a3/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Pyhton 处理 excel 文档
这是一篇对使用python进行excel文档数据处理的一些技术说明。
依赖包:numpy, pandas
pd.read_excel
dtype: 制定数据类型
engine: 数据分析引擎
使用read_excel可以读取excel中的内容,返回dataFrame的数据格式。
pd.read_csv
使用read_csv可以读取csv文件,返回dataFrame的数据格式。
dataFrame.merge | dataFrame.join
merge以列为基准去合并
join以行为基准去合并
pd.Series
生成 Series 格式的数据,多个Series组合成dataFrame。
dataFram[[“a”, “b”]]
截取列数据
dataFrame.rename
columns={“name_source”: “name_renamed”}
如果想要对数据中的列进行重命名,则需要rename,里面提供columns参数。
pd.pivot_table
values
columns
index
如果要对数据进行分组,出了groupby外,还可用pivot_table,pivot_table是商学院里面教学的工具,使用非常广泛。
dataFrame.to_excel
parameter: path_file_with_name
将dataFrame输出到Excel表格里面。
欢迎大家关顾我的Facebook主页「Y Life Book」以及我的公众微信号「不点语书」,我们下期见。
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK